Lazy load all plugin parts

This commit is contained in:
Chi Vinh Le
2017-04-03 14:25:06 +07:00
parent 73e2b899d8
commit 62c4072631
4 changed files with 23 additions and 18 deletions
+2 -2
View File
@@ -6,7 +6,7 @@ import isEqual from 'lodash/isEqual';
import I18n from 'coral-framework/modules/i18n/i18n';
import translations from 'coral-framework/translations';
const lang = new I18n(translations);
import {queriesAndMutators as pluginQueriesAndMutators} from 'coral-framework/helpers/plugins';
import {getPluginQueriesAndMutators} from 'coral-framework/helpers/plugins';
import {TabBar, Tab, TabContent, Spinner} from 'coral-ui';
@@ -306,5 +306,5 @@ export default compose(
removeCommentTag,
deleteAction,
queryStream,
...pluginQueriesAndMutators,
...getPluginQueriesAndMutators(),
)(Embed);
+2 -2
View File
@@ -1,11 +1,11 @@
import * as authActions from './auth';
import * as assetActions from './asset';
import * as notificationActions from './notification';
import {actions as pluginActions} from '../helpers/plugins';
import {getPluginActions} from '../helpers/plugins';
export default {
authActions,
assetActions,
notificationActions,
pluginActions,
pluginActions: getPluginActions(),
};
+17 -12
View File
@@ -24,17 +24,22 @@ export function getSlotElements(slot, props = {}) {
.map(o => React.createElement(o.component, o.props));
}
// actions is a map of redux actions .
export const actions = merge(...plugins.actions.map(o => ({...o.module()})));
// Returns a map of redux actions.
export function getPluginActions() {
return merge(...plugins.actions.map(o => ({...o.module()})));
}
// reducers is a map of redux reducers.
export const reducers = merge(...plugins.reducers.map(o => ({...o.module()})));
// queriesAndMutators is an array of graphQL queries and mutators.
export const queriesAndMutators = flatten(
merge(
plugins.queries.map(o => values(o.module())),
plugins.mutators.map(o => values(o.module())),
)
);
// Returns a map of redux reducers.
export function getPluginReducers() {
merge(...plugins.reducers.map(o => ({...o.module()})));
}
// Returns an array of graphQL queries and mutators.
export function getPluginQueriesAndMutators() {
return flatten(
merge(
plugins.queries.map(o => values(o.module())),
plugins.mutators.map(o => values(o.module())),
)
);
}
+2 -2
View File
@@ -1,11 +1,11 @@
import auth from './auth';
import user from './user';
import asset from './asset';
import {reducers as pluginReducers} from '../helpers/plugins';
import {getPluginReducers} from '../helpers/plugins';
export default {
auth,
user,
asset,
...pluginReducers
...getPluginReducers()
};