aboutsummaryrefslogtreecommitdiff
path: root/src/background
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-10-07 12:21:09 +0900
committerGitHub <noreply@github.com>2017-10-07 12:21:09 +0900
commitd995ab0030522f380d165f309ffc72b582366ddb (patch)
tree69a096e9a8610ae8966af05e91355efdd27ea811 /src/background
parent482206f6c90985011b197623854b8bfbc26ee54c (diff)
parent9fb7bf96be786acfbad97f7c76bc423a401dd657 (diff)
Merge pull request #19 from ueokande/content-and-background-redux-completely
Refactor: full redux on content and background
Diffstat (limited to 'src/background')
-rw-r--r--src/background/index.js36
1 files changed, 15 insertions, 21 deletions
diff --git a/src/background/index.js b/src/background/index.js
index e968c82..b966c13 100644
--- a/src/background/index.js
+++ b/src/background/index.js
@@ -1,30 +1,24 @@
-import * as consoleActions from '../actions/console';
-import * as settingsActions from '../actions/setting';
-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 * as settingsActions from 'actions/setting';
+import messages from 'content/messages';
+import BackgroundComponent from 'components/background';
+import BackgroundInputComponent from 'components/background-input';
+import reducers from 'reducers';
+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);
+ return browser.tabs.sendMessage(sender.tab.id, {
+ type: messages.CONSOLE_SHOW_ERROR,
+ text: e.message,
+ });
}
});
-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) => {
- if (sender) {
- return browser.tabs.sendMessage(sender.tab.id, {
- type: messages.STATE_UPDATE,
- state: backgroundStore.getState()
- });
- }
-});
-backgroundStore.dispatch(settingsActions.load());
+store.dispatch(settingsActions.load());