diff --git a/src/background/index.js b/src/background/index.js index e968c82..9a1adc6 100644 --- a/src/background/index.js +++ b/src/background/index.js @@ -4,27 +4,27 @@ import BackgroundComponent from '../components/background'; import BackgroundInputComponent from '../components/background-input'; import reducers from '../reducers'; import messages from '../content/messages'; -import * as store from '../store'; +import { createStore } from '../store'; -const backgroundStore = store.createStore(reducers, (e, sender) => { +const store = createStore(reducers, (e, sender) => { console.error('Vim-Vixen:', e); if (sender) { - backgroundStore.dispatch(consoleActions.showError(e.message), sender); + store.dispatch(consoleActions.showError(e.message), sender); } }); -const backgroundComponent = new BackgroundComponent(backgroundStore); -const backgroundInputComponent = new BackgroundInputComponent(backgroundStore); -backgroundStore.subscribe((sender) => { +const backgroundComponent = new BackgroundComponent(store); +const backgroundInputComponent = new BackgroundInputComponent(store); +store.subscribe((sender) => { backgroundComponent.update(sender); backgroundInputComponent.update(sender); }); -backgroundStore.subscribe((sender) => { +store.subscribe((sender) => { if (sender) { return browser.tabs.sendMessage(sender.tab.id, { type: messages.STATE_UPDATE, - state: backgroundStore.getState() + state: store.getState() }); } }); -backgroundStore.dispatch(settingsActions.load()); +store.dispatch(settingsActions.load()); diff --git a/src/content/index.js b/src/content/index.js index 655bea4..ea08982 100644 --- a/src/content/index.js +++ b/src/content/index.js @@ -3,16 +3,16 @@ import * as consoleFrames from './console-frames'; import * as scrolls from '../content/scrolls'; import * as navigates from '../content/navigates'; import * as followActions from '../actions/follow'; -import * as store from '../store'; +import { createStore } from '../store'; import ContentInputComponent from '../components/content-input'; import FollowComponent from '../components/follow'; import followReducer from '../reducers/follow'; import operations from '../operations'; import messages from './messages'; -const followStore = store.createStore(followReducer); -const followComponent = new FollowComponent(window.document.body, followStore); -followStore.subscribe(() => { +const store = createStore(followReducer); +const followComponent = new FollowComponent(window.document.body, store); +store.subscribe(() => { try { followComponent.update(); } catch (e) { @@ -39,7 +39,7 @@ const execOperation = (operation) => { case operations.SCROLL_END: return scrolls.scrollRight(window); case operations.FOLLOW_START: - return followStore.dispatch(followActions.enable(false)); + return store.dispatch(followActions.enable(false)); case operations.NAVIGATE_HISTORY_PREV: return navigates.historyPrev(window); case operations.NAVIGATE_HISTORY_NEXT: diff --git a/src/pages/console.js b/src/pages/console.js index 2cbea25..4ce9e47 100644 --- a/src/pages/console.js +++ b/src/pages/console.js @@ -3,26 +3,26 @@ import messages from '../content/messages'; import CompletionComponent from '../components/completion'; import ConsoleComponent from '../components/console'; import completionReducer from '../reducers/completion'; -import * as store from '../store'; +import { createStore } from '../store'; import * as completionActions from '../actions/completion'; -const completionStore = store.createStore(completionReducer); +const store = createStore(completionReducer); let completionComponent = null; let consoleComponent = null; let prevState = {}; window.addEventListener('load', () => { let wrapper = document.querySelector('#vimvixen-console-completion'); - completionComponent = new CompletionComponent(wrapper, completionStore); + completionComponent = new CompletionComponent(wrapper, store); - // TODO use root root store instead of completionStore - consoleComponent = new ConsoleComponent(document.body, completionStore); + // TODO use root root store instead of store + consoleComponent = new ConsoleComponent(document.body, store); }); -completionStore.subscribe(() => { +store.subscribe(() => { completionComponent.update(); - let state = completionStore.getState(); + let state = store.getState(); if (state.groupSelection >= 0) { let item = state.groups[state.groupSelection].items[state.itemSelection]; @@ -40,6 +40,6 @@ browser.runtime.onMessage.addListener((action) => { if (action.type === messages.STATE_UPDATE) { let state = action.state.console; consoleComponent.update(state); - completionStore.dispatch(completionActions.setItems(state.completions)); + store.dispatch(completionActions.setItems(state.completions)); } }); diff --git a/src/pages/settings.js b/src/pages/settings.js index 9bad967..076d23d 100644 --- a/src/pages/settings.js +++ b/src/pages/settings.js @@ -1,15 +1,15 @@ import './settings.scss'; import SettingComponent from '../components/setting'; import settingReducer from '../reducers/setting'; -import * as store from '../store'; +import { createStore } from '../store'; -const settingStore = store.createStore(settingReducer); +const store = createStore(settingReducer); let settingComponent = null; -settingStore.subscribe(() => { +store.subscribe(() => { settingComponent.update(); }); document.addEventListener('DOMContentLoaded', () => { - settingComponent = new SettingComponent(document.body, settingStore); + settingComponent = new SettingComponent(document.body, store); });