aboutsummaryrefslogtreecommitdiff
path: root/src/background/Application.ts
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-05-22 20:16:21 +0900
committerGitHub <noreply@github.com>2019-05-22 20:16:21 +0900
commitc1f64927b63d18048790abd3ba907083dbca3084 (patch)
tree3a64b677763f62094c49527d8182f8756a52fbd1 /src/background/Application.ts
parentced89134e32d793d8e091113cfb20867e1c3b572 (diff)
parent7be8bc71784b8dedd0fee03dd72dd8936e2f3929 (diff)
Merge pull request #588 from ueokande/tsyringe
Use tsyringe for DI container
Diffstat (limited to 'src/background/Application.ts')
-rw-r--r--src/background/Application.ts35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/background/Application.ts b/src/background/Application.ts
new file mode 100644
index 0000000..08013cd
--- /dev/null
+++ b/src/background/Application.ts
@@ -0,0 +1,35 @@
+import { injectable } from 'tsyringe';
+import ContentMessageListener from './infrastructures/ContentMessageListener';
+import SettingController from './controllers/SettingController';
+import VersionController from './controllers/VersionController';
+
+@injectable()
+export default class Application {
+ constructor(
+ private contentMessageListener: ContentMessageListener,
+ private settingController: SettingController,
+ private versionController: VersionController,
+ ) {
+ }
+
+ run() {
+ this.settingController.reload();
+
+ browser.runtime.onInstalled.addListener((details) => {
+ if (details.reason !== 'install' && details.reason !== 'update') {
+ return;
+ }
+ this.versionController.notify();
+ });
+
+ this.contentMessageListener.run();
+ browser.storage.onChanged.addListener((changes, area) => {
+ if (area !== 'local') {
+ return;
+ }
+ if (changes.settings) {
+ this.settingController.reload();
+ }
+ });
+ }
+}