Skip to content
Snippets Groups Projects
Commit 592e8b1e authored by Chris Beer's avatar Chris Beer
Browse files

Move the redux store into the viewer instance

parent 6b13ab2f
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,6 @@ import createStore from '../state/createStore';
import * as actions from '../state/actions';
import settings from '../config/settings';
const store = createStore();
/**
* Default Mirador instantiation
*/
......@@ -16,16 +15,17 @@ class MiradorViewer {
/**
*/
constructor(config) {
this.store = createStore();
this.config = config;
this.processPlugins();
this.processConfig();
const viewer = {
actions,
store,
store: this.store,
};
ReactDOM.render(
<Provider store={store}>
<Provider store={this.store}>
<App config={config} />
</Provider>,
document.getElementById(config.id),
......@@ -40,7 +40,7 @@ class MiradorViewer {
processConfig() {
const mergedConfig = deepmerge(settings, this.config);
const action = actions.setConfig(mergedConfig);
store.dispatch(action);
this.store.dispatch(action);
mergedConfig.windows.forEach((miradorWindow) => {
let thumbnailNavigationPosition;
......@@ -49,8 +49,8 @@ class MiradorViewer {
} else {
thumbnailNavigationPosition = mergedConfig.thumbnailNavigation.defaultPosition;
}
store.dispatch(actions.fetchManifest(miradorWindow.loadedManifest));
store.dispatch(actions.addWindow({
this.store.dispatch(actions.fetchManifest(miradorWindow.loadedManifest));
this.store.dispatch(actions.addWindow({
canvasIndex: (miradorWindow.canvasIndex || 0),
manifestId: miradorWindow.loadedManifest,
thumbnailNavigationPosition,
......@@ -88,8 +88,8 @@ class MiradorViewer {
});
actionCreators.forEach((action) => { actions[action.name] = action.action; });
reducers.forEach((reducer) => { store.pluginReducers[reducer.name] = reducer.reducer; });
store.replaceReducer(createRootReducer(store.pluginReducers));
reducers.forEach((reducer) => { this.store.pluginReducers[reducer.name] = reducer.reducer; });
this.store.replaceReducer(createRootReducer(this.store.pluginReducers));
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment