Skip to content

Commit

Permalink
refactor: exporting controllers instances from controller/index.ts
Browse files Browse the repository at this point in the history
Extracting the view controller instances into a common file.

re DTStack#52
  • Loading branch information
wewoor authored and mumiao committed Feb 25, 2021
1 parent a3c8d85 commit 3d9efa5
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 22 deletions.
20 changes: 20 additions & 0 deletions src/controller/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { container } from 'tsyringe';
import { ActivityBarController } from './activityBar';
import { EditorController } from './editor';
import { ExplorerController } from './explorer/explorer';
import { FolderTreeController } from './explorer/folderTree';
import { MenuBarController } from './menuBar';
import { PanelController } from './panel';
import { SettingsController } from './settings';
import { SidebarController } from './sidebar';
import { StatusBarController } from './statusBar';

export const activityBarController = container.resolve(ActivityBarController);
export const editorController = container.resolve(EditorController);
export const menuBarController = container.resolve(MenuBarController);
export const panelController = container.resolve(PanelController);
export const sidebarController = container.resolve(SidebarController);
export const explorerController = container.resolve(ExplorerController);
export const statusBarController = container.resolve(StatusBarController);
export const settingsController = container.resolve(SettingsController);
export const folderTreeController = container.resolve(FolderTreeController);
5 changes: 1 addition & 4 deletions src/workbench/menuBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import { menuBarService } from 'mo/services';
import { connect } from 'mo/react';

import MenuBar from './menuBar';
import { container } from 'tsyringe';
import { MenuBarController } from 'mo/controller/menuBar';

const menuBarController = container.resolve(MenuBarController);
import { menuBarController } from 'mo/controller';

const MenuBarView = connect(menuBarService, MenuBar, menuBarController);

Expand Down
5 changes: 1 addition & 4 deletions src/workbench/panel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { connect, panelService } from 'mo';
import { PanelController } from 'mo/controller/panel';
import { container } from 'tsyringe';
import { panelController } from 'mo/controller';
import Panel from './panel';

const panelController = container.resolve(PanelController);

const PanelView = connect(panelService, Panel, panelController);

export { PanelView };
6 changes: 1 addition & 5 deletions src/workbench/sidebar/explore/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { ExplorerController } from 'mo/controller/explorer/explorer';
import { FolderTreeController } from 'mo/controller/explorer/folderTree';
import { connect } from 'mo/react';
import { explorerService } from 'mo/services';
import { container } from 'tsyringe';
import { explorerController, folderTreeController } from 'mo/controller';
import { Explorer } from './explore';
import FolderTree from './folderTree';

const explorerController = container.resolve(ExplorerController);
const folderTreeController = container.resolve(FolderTreeController);
const ExplorerView = connect(explorerService, Explorer, explorerController);
const FolderTreeView = connect(
explorerService,
Expand Down
6 changes: 1 addition & 5 deletions src/workbench/sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ export * from './sidebar';
import { Sidebar } from './sidebar';
import { sidebarService } from 'mo/services';
import { connect } from 'mo/react';
import { SidebarController } from 'mo/controller/sidebar';
import { container } from 'tsyringe';
import './explore';

const sidebarController = container.resolve(SidebarController);
import { sidebarController } from 'mo/controller';

export const SidebarView = connect(sidebarService, Sidebar, sidebarController);
5 changes: 1 addition & 4 deletions src/workbench/statusBar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { statusBarController } from 'mo/controller';
import { connect } from 'mo/react';
import { statusBarService } from 'mo/services';
import StatusBar from './statusBar';
import { StatusBarController } from 'mo/controller/statusBar';
import { container } from 'tsyringe';

export * from './statusBar';

const statusBarController = container.resolve(StatusBarController);

export const StatusBarView = connect(
statusBarService,
StatusBar,
Expand Down

0 comments on commit 3d9efa5

Please sign in to comment.