Action
A redux-fluent action is a flux standard action by design. We wanted to adopt a clear design pattern, that's it. Please, refer to the FSA documentation to understand why a Flux Standard Action "is Useful, Simple and Human Friendly!"
// todos.actions.js
import { createAction } from 'redux-fluent';
export const addTodo = createAction('ADD_TODO');
export const editTodo = createAction('EDIT_TODO');
export const deleteTodo = createAction('DELETE_TODO');
Actions are payloads of information that send data from your application to your store. They are the only source of information for the store. You send them to the store using
store.dispatch()
.
import { addTodo } from './todos.actions.js';
store.dispatch(
addTodo({ title: 'Have some fun' }),
);
Action Types
We wanted to remove all the boilerplate that is normally involved in standard redux projects. You no longer need to either declare or export constants.
import { addTodo } from './todos.actions.js';
console.log(addTodo.type);
// 'ADD_TODO'
All-In-One
A redux-fluent action squeezes all the concepts of action, action type and action creator together. All you need is a one-line declaration. That's it!