From 5602bc039b7f49ee9d74582ade5551dbd3338126 Mon Sep 17 00:00:00 2001 From: Byron Hulcher Date: Tue, 21 Mar 2017 19:49:21 -0400 Subject: [PATCH] Fixes for example code (#433) * Added bel, choo-persist, and choo-log to dependencies * Fixed bug in example code where deletes were not updating active/done lists correctly --- example/index.js | 14 ++++++++++++-- example/package.json | 3 +++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/example/index.js b/example/index.js index a7b3c09..c3a7f73 100644 --- a/example/index.js +++ b/example/index.js @@ -131,11 +131,21 @@ function todoStore (state, emitter) { if (todo.done) { var done = state.todos.done - var doneIndex = done[todo] + var doneIndex + done.forEach(function (_todo, j) { + if (_todo.id === id) { + doneIndex = j + } + }) done.splice(doneIndex, 1) } else { var active = state.todos.active - var activeIndex = active[todo] + var activeIndex + active.forEach(function (_todo, j) { + if (_todo.id === id) { + activeIndex = j + } + }) active.splice(activeIndex, 1) } emitter.emit('render') diff --git a/example/package.json b/example/package.json index 246ec0b..b47ffe7 100644 --- a/example/package.json +++ b/example/package.json @@ -9,7 +9,10 @@ "test": "standard && npm run deps && node test.js" }, "dependencies": { + "bel": "^4.5.1", "choo-expose": "^1.0.0", + "choo-log": "^5.0.0", + "choo-persist": "^3.0.0", "sheetify": "^6.0.1", "todomvc-app-css": "^2.0.6", "todomvc-common": "^1.0.3",