/** * Async Method * Dispatch a reducer thought the store. This the unique manner to modify the store. * @param{Function(Object,...rest)} action The reducer to be dispatched, that will modify the store. * Action got the state of the store as first arguments and 'rest' next. * @param{*} rest Rest of arguments passed to middlewares and to the action. */ async dispatch(reducer= (state) => state,...rest)
Define dispatchers in a dedicated file. Just import todoStore and have access to the dispatch method to update all connected component.
connect is a High Order Component (react-redux.connect). It's create a component that listen for changes comming from the given store.
TIPS: To integrate RxStore with another view library, you may override connect
todo.container.jsx
import todoStore from'./todo.store.js';functionTodoContainer({todos}){...}functionmapStateToProps({ todos }, props) {// Work very well with 'reselect'.let _todos =todos.sort((t1, t2) =>t1.id <t2.id);return { todos: _todos };}exportdefaulttodoStore.connect(mapStateToProps)(TodoContainer);