Ported for Atom from https://github.com/alanvivona/rxjs-snippets-vscode with addition of redux-observable snippets.
/**
* Import all your Epics and Reducers into single file each, which then
* exports the root Epic
*/
import { combineEpics } from 'redux-observable';
import { combineReducers } from 'redux';
import ${1:ObjectName1}, { ${1:ObjectName1}Epic } from './${1:ObjectName1}';
import ${2:ObjectName2}, { ${2:ObjectName2}Epic } from './${2:ObjectName2}';
export const rootEpic = combineEpics(
${1:ObjectName1}Epic,
${2:ObjectName2}Epic
);
export const rootReducer = combineReducers({
${1:ObjectName1},
${2:ObjectName2}
});
/**
* configureStore
*/
import { createStore, applyMiddleware } from 'redux';
import { createEpicMiddleware } from 'redux-observable';
import { rootEpic, rootReducer } from './modules/root';
const epicMiddleware = createEpicMiddleware(rootEpic);
export default function configureStore() {
const store = createStore(
rootReducer,
applyMiddleware(epicMiddleware)
);
return store;
}
/**
* ${1:epicName} epic sample
*/
const ${1:epicName}Epic = action$ =>
action$.filter(action => action.type === ${2:ACTION1})
.mapTo({ type: ${3:ACTION2} });
// later...
dispatch({ type: ${2:ACTION1} });