From cdabe22e59d814022a0836af0fc87a9bd8190327 Mon Sep 17 00:00:00 2001 From: Tim Wisniewski Date: Tue, 16 Aug 2016 09:50:56 -0400 Subject: [PATCH] Readme: fix effects example (#223) Per #186. We could introduce `xtend` here to make a copy of `data` in order to keep it `addAndSave`, but if the purpose of this example is to illustrate an effect, that may seem overkill (unless accompanied by a longer explanation. --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f33f2ea..5a388c4 100644 --- a/README.md +++ b/README.md @@ -297,15 +297,16 @@ app.model({ namespace: 'todos', state: { items: [] }, effects: { - addAndSave: (data, state, send, done) => { - http.post('/todo', {json: data.payload}, (err, res, body) => { - data.payload.id = body.id - send('todos:add', data, done) + fetch: (data, state, send, done) => { + http('/todos', (err, res, body) => { + send('todos:receive', body, done) }) } }, reducers: { - add: (data, state) => ({ items: state.items.concat(data.payload) }) + receive: (data, state) => { + return { items: data } + } } }) ```