From df65c6dbb4905a5139fa6d233ac4c00c0308c615 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 5 Aug 2019 17:27:45 +0900 Subject: [PATCH] refactor(neuron-wallet): Delete Router class --- packages/neuron-wallet/src/main.ts | 7 ------- packages/neuron-wallet/src/router.ts | 18 ------------------ 2 files changed, 25 deletions(-) delete mode 100644 packages/neuron-wallet/src/router.ts diff --git a/packages/neuron-wallet/src/main.ts b/packages/neuron-wallet/src/main.ts index e7d1468f3e..fe4f0e065c 100644 --- a/packages/neuron-wallet/src/main.ts +++ b/packages/neuron-wallet/src/main.ts @@ -4,7 +4,6 @@ import { debounceTime } from 'rxjs/operators' import i18n from 'utils/i18n' import { updateApplicationMenu } from 'utils/application-menu' -import Router from 'router' import WindowManager from 'models/window-manager' import createMainWindow from 'startup/create-main-window' import createSyncBlockTask from 'startup/sync-block-task/create' @@ -15,12 +14,6 @@ import dataUpdateSubject from 'models/subjects/data-update' const walletsService = WalletsService.getInstance() -const router = new Router() - -Object.defineProperty(app, 'router', { - value: router, -}) - const openWindow = () => { if (!WindowManager.mainWindow) { WindowManager.mainWindow = createMainWindow() diff --git a/packages/neuron-wallet/src/router.ts b/packages/neuron-wallet/src/router.ts deleted file mode 100644 index ee2eb7527a..0000000000 --- a/packages/neuron-wallet/src/router.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { ipcMain } from 'electron' -import controllers from 'controllers' -import logger from 'utils/logger' - -export default class Router { - constructor(controllerSet: typeof controllers = controllers) { - Object.values(controllerSet).forEach(controller => { - if (typeof controller === 'function') { - const channel = Reflect.getMetadata('channel', controller) || controller.name.toLowerCase().slice(0, -10) - ipcMain.on(channel, async (e: Electron.Event, method: keyof typeof controller, ...params: any[]) => { - e.sender.send(channel, method, await (controller[method] as Function)(...params)) - }) - } else { - logger.log({ level: 'error', message: `${controller} is invalid` }) - } - }) - } -}