Skip to content

Instantly share code, notes, and snippets.

@StevenLangbroek
Last active July 12, 2017 20:40
Show Gist options
  • Save StevenLangbroek/53d730a5effb534dd47e4f6384c00c13 to your computer and use it in GitHub Desktop.
Save StevenLangbroek/53d730a5effb534dd47e4f6384c00c13 to your computer and use it in GitHub Desktop.
import { createReducer } from 'src/utils';
const LOAD_POST = 'LOAD_POST';
const LOAD_POST_SUCCESS = 'LOAD_POST_SUCCESS';
const LOAD_POST_FAIL = 'LOAD_POST_FAIL';
const initialState = {
$isLoading: false,
$didFailLoading: false,
post: null,
};
// action creators, exports etc etc etc, you get the point. this is in our case generated by an internal
// yeoman generator by running `yo generate reducer post` or some such.
// this works, but if we streamline things we either have to write a codemod or manually refactor
// all the generated bits.
import reducer from 'reducer.macro';
reducer('post')
// doing it this way could result in the same code, but if we change the underlying macro
// we wouldn't need to write said codemods or refactor individual reducers....
// we'd obviously have to put some more thought into api flexibility / escape hatches,
// but that's a trade-off I can see leaning towards macro's in some of our use-cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment