From 4d75e2229354fbf8a4b5a6c943f15babb63ad685 Mon Sep 17 00:00:00 2001 From: Samuli Ulmanen Date: Wed, 6 Apr 2016 09:10:52 +0300 Subject: [PATCH 1/2] todo app remaining tasks reducer func fixed and clarified --- public/docs/_examples/homepage-todo/ts/app/todo_app.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/docs/_examples/homepage-todo/ts/app/todo_app.ts b/public/docs/_examples/homepage-todo/ts/app/todo_app.ts index 5688868b73..2aea133efd 100644 --- a/public/docs/_examples/homepage-todo/ts/app/todo_app.ts +++ b/public/docs/_examples/homepage-todo/ts/app/todo_app.ts @@ -23,7 +23,7 @@ export class TodoApp { ]; get remaining() { - return this.todos.reduce((count: number, todo: Todo) => count + +!todo.done, 0); + return this.todos.reduce((count: number, todo: Todo) => todo.done ? count : ++count, 0); } archive(): void { From f844c02404088e855d4a36cd32f882d0b044d3d6 Mon Sep 17 00:00:00 2001 From: Samuli Ulmanen Date: Wed, 6 Apr 2016 10:34:39 +0300 Subject: [PATCH 2/2] filter is better suited to get todo app remaining count --- public/docs/_examples/homepage-todo/ts/app/todo_app.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/docs/_examples/homepage-todo/ts/app/todo_app.ts b/public/docs/_examples/homepage-todo/ts/app/todo_app.ts index 2aea133efd..996a003d0d 100644 --- a/public/docs/_examples/homepage-todo/ts/app/todo_app.ts +++ b/public/docs/_examples/homepage-todo/ts/app/todo_app.ts @@ -23,7 +23,7 @@ export class TodoApp { ]; get remaining() { - return this.todos.reduce((count: number, todo: Todo) => todo.done ? count : ++count, 0); + return this.todos.filter((todo: Todo) => !todo.done).length; } archive(): void {