Example of Reduxible Actions
app.js
import Reduxible from 'reduxible';
import ...
const reduxible = new Reduxible({
server: true,
development: true,
universal: true,
container: Html,
errorContainer: Error,
devTools:
routes,
middlewares,
reducers,
reloader,
initialActions,
extras: extras
});
todoService.js
import { createAction, createReducer } from 'reduxible';
export const action = createAction('todo', {
ADD_TODO: (todo) => ({ payload: { todo } })
});
export default createReducer({todos: []},[
{
types: [ action.type('ADD_TODO') ],
reduce: (payload, state) => {
const { todo } = payload;
const todos = [...state.todos, todo];
return {
...state,
todos
};
}
},
...
]);
reducers.js
import { combineRouteReducers } from 'reduxible';
import todo from './todoService';
export default combineRouteReducers({
todo
})
Todo.js
import { action } from './todoService';
...
@connect(state => { todos: state.todo.todos },{ updateTodo : action('UPDATE_TODO') })
class Todo extend Component {
...
}