Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added appEpics #1644

Merged
merged 3 commits into from
Mar 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web/client/jsapi/MapStore2.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ const MapStore2 = {
pages
}))(require('../components/app/StandardRouter'));

const appStore = require('../stores/StandardStore').bind(null, initialState || {}, {});
const appStore = require('../stores/StandardStore').bind(null, initialState || {}, {}, {});
const initialActions = getInitialActions(options);
const appConfig = {
storeOpts: assign({}, storeOpts, {notify: true}),
Expand Down
2 changes: 1 addition & 1 deletion web/client/product/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const startApp = () => {
const appStore = require('../stores/StandardStore').bind(null, initialState, {
home: require('./reducers/home'),
maps: require('../reducers/maps')
});
}, {});

const initialActions = [
() => loadMaps(ConfigUtils.getDefaults().geoStoreUrl, ConfigUtils.getDefaults().initialMapFilter || "*")
Expand Down
4 changes: 2 additions & 2 deletions web/client/stores/StandardStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const {createEpicMiddleware} = require('redux-observable');
const SecurityUtils = require('../utils/SecurityUtils');
const ListenerEnhancer = require('@carnesen/redux-add-action-listener-enhancer').default;

module.exports = (initialState = {defaultState: {}, mobile: {}}, appReducers = {}, plugins, storeOpts) => {
module.exports = (initialState = {defaultState: {}, mobile: {}}, appReducers = {}, appEpics = {}, plugins, storeOpts) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New arguments at the end, for compatibility reasons, please

Copy link
Member

@offtherailz offtherailz Mar 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This signature is better. This doesn't break the binding with StandardApp or other apps. I should put it in that place instead of the bottom.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Binding appEpics wouldn't be possible

const allReducers = combineReducers(plugins, {
...appReducers,
localConfig: require('../reducers/localConfig'),
Expand All @@ -39,7 +39,7 @@ module.exports = (initialState = {defaultState: {}, mobile: {}}, appReducers = {
mapInitialConfig: () => {return null; },
layers: () => {return null; }
});
const rootEpic = combineEpics(plugins);
const rootEpic = combineEpics(plugins, appEpics);
const defaultState = initialState.defaultState;
const mobileOverride = initialState.mobile;
const epicMiddleware = createEpicMiddleware(rootEpic);
Expand Down
6 changes: 3 additions & 3 deletions web/client/utils/PluginsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ const PluginsUtils = {
* @param {function[]} [epics] the epics to add to the plugins' ones
* @return {function} the rootEpic, obtained combining plugins' epics and the other epics passed as argument.
*/
combineEpics: (plugins, epics = []) => {
const pluginEpics = getEpics(plugins);
return combineEpics(...[ ...Object.keys(pluginEpics).map(k => pluginEpics[k]), ...epics]);
combineEpics: (plugins, epics = {}) => {
const pluginEpics = assign({}, getEpics(plugins), epics);
return combineEpics( ...Object.keys(pluginEpics).map(k => pluginEpics[k]));
},
getReducers,
filterState,
Expand Down
7 changes: 7 additions & 0 deletions web/client/utils/__tests__/PluginUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
const expect = require('expect');
const PluginsUtils = require('../PluginsUtils');
const assign = require('object-assign');
const MapSearchPlugin = require('../../plugins/MapSearch');

describe('PluginsUtils', () => {
beforeEach( () => {
Expand Down Expand Up @@ -72,5 +73,11 @@ describe('PluginsUtils', () => {
expect(desc1.items[0].cfg).toExist();

});
it('combineEpics', () => {
const plugins = {MapSearchPlugin: MapSearchPlugin};
const appEpics = {appEpics: (actions$) => actions$.ofType('TEST_ACTION').map({type: "NEW_ACTION_TEST"})};
const epics = PluginsUtils.combineEpics(plugins, appEpics);
expect(typeof epics ).toEqual('function');
});

});