From 5fc2cab1f01ec203ff9edafda4f74b59b306ec26 Mon Sep 17 00:00:00 2001 From: Tim Wisniewski Date: Fri, 8 Jul 2016 06:13:39 -0400 Subject: [PATCH] Correct model namespace example (#143) --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ced5ebd..c97fc80 100644 --- a/README.md +++ b/README.md @@ -236,17 +236,17 @@ namespaced or not. Namespacing means that only state within the model can be accessed. Models can still trigger actions on other models, though it's recommended to keep that to a minimum. -So say we have a `myTodos` namespace, an `add` reducer and a `todos` model. +So say we have a `todos` namespace, an `add` reducer and a `todos` model. Outside the model they're called by `send('todos:add')` and -`state.todos.todos`. Inside the namespaced model they're called by -`send('todos:add')` and `state.todos`. An example namespaced model: +`state.todos.items`. Inside the namespaced model they're called by +`send('todos:add')` and `state.items`. An example namespaced model: ```js const app = choo() app.model({ - namespace: 'myTodos', - state: { todos: [] }, + namespace: 'todos', + state: { items: [] }, reducers: { - add: (data, state) => ({ todos: state.todos.concat(data.payload) }) + add: (data, state) => ({ todos: state.items.concat(data.payload) }) } }) ```