Skip to content

Instantly share code, notes, and snippets.

@pie6k
Created February 3, 2017 10:19
Show Gist options
  • Save pie6k/2c51906b1bd3eae204f98a31fc56fda5 to your computer and use it in GitHub Desktop.
Save pie6k/2c51906b1bd3eae204f98a31fc56fda5 to your computer and use it in GitHub Desktop.
// SomeComponent.js
import incrementCounter from 'counter/actions'; // example
<Button onClick={incrementCounter(10)}
// counter/actions.js
import {createAction} from 'actionFactory';
export function incrementCounter((state, count) => state.counter += count);
// actionFactory.js
import store from './store.js';
export function createAction(reducerFunc, description = '') {
const action = createActionAct();
action.assignTo(store); // !!!!!!!!!! it makes us dont need to care about store when we'll use this action!
reducer.on(action, reducerFunc);
return action;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment