From 6fd7d4855f26aa7f217094f815fc7c2ec14bed4f Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Tue, 28 Dec 2021 13:06:11 +0100 Subject: refactor: Get rid of dependency injector --- packages/main/src/CompositionRoot.ts | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 packages/main/src/CompositionRoot.ts (limited to 'packages/main/src/CompositionRoot.ts') diff --git a/packages/main/src/CompositionRoot.ts b/packages/main/src/CompositionRoot.ts new file mode 100644 index 0000000..affb186 --- /dev/null +++ b/packages/main/src/CompositionRoot.ts @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2021-2022 Kristóf Marussy + * + * This file is part of Sophie. + * + * Sophie is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import { app } from 'electron'; + +import { ConfigController } from './controllers/ConfigController'; +import { NativeThemeController } from './controllers/NativeThemeController'; +import { ConfigPersistenceService } from './services/ConfigPersistenceService'; +import { MainStore } from './stores/MainStore'; +import { DisposeHelper } from './utils'; + +export class CompositionRoot extends DisposeHelper { + async init(store: MainStore): Promise { + const configPersistenceService = new ConfigPersistenceService(app.getPath('userData')); + await this.registerDisposable(new ConfigController( + configPersistenceService, + )).connect(store.config); + this.registerDisposable(new NativeThemeController()).connect(store); + } +} -- cgit v1.2.3-70-g09d2