Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import saga from "./sagas";
import { editorSelectionChanged } from "../../Edit/actions";
import { setValue } from "../../Edit/components/AddEntity/actions";
import { WORDLIFT_STORE } from "../../common/constants";
const initialState = { entities: Map() };
const sagaMiddleware = createSagaMiddleware();
const store = createStore(
combineReducers({ entities, annotationFilter, visibilityFilter, blockEditor, createEntityForm, relatedPosts }),
initialState,
applyMiddleware(sagaMiddleware, logger)
);
sagaMiddleware.run(saga);
// Register the store with WordPress.
registerGenericStore(WORDLIFT_STORE, {
getSelectors() {
return {
getAnnotationFilter: (...args) => getAnnotationFilter(store.getState(), ...args),
getEditor: (...args) => getEditor(store.getState(), ...args),
getEntities: (...args) => getEntities(store.getState(), ...args),
getSelectedEntities: (...args) => getSelectedEntities(store.getState(), ...args),
getBlockEditor: (...args) => getBlockEditor(store.getState(), ...args),
getBlockEditorFormat: (...args) => getBlockEditorFormat(store.getState(), ...args)
};
},
getActions() {
return {
editorSelectionChanged: args => store.dispatch(editorSelectionChanged(args)),
requestAnalysis: (...args) => store.dispatch(requestAnalysis(...args)),
// Called when the selection changes in editor.
setValue: args => store.dispatch(setValue(args)),
const mappedActions = Object.keys( actions ).reduce( ( acc, actionKey ) => {
acc[ actionKey ] = ( ...args ) => reduxStore.dispatch( actions[ actionKey ]( ...args ) );
return acc;
}, {} );
const genericStore = {
getSelectors() {
return mappedSelectors;
},
getActions() {
return mappedActions;
},
subscribe: reduxStore.subscribe,
};
registerGenericStore( STORE_KEY_EDIT_POD, genericStore );
};