Skip to content

Commit

Permalink
feat: declare service interface
Browse files Browse the repository at this point in the history
  • Loading branch information
wewoor committed Oct 28, 2020
1 parent ed499e9 commit 6ccd70c
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 277 deletions.
3 changes: 1 addition & 2 deletions src/extensions/activityBar/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { activityBar } from 'mo/index';
import { ActivityBarEvent, IActivityBarItem } from 'mo/core/workbench/activityBar';
import { activityBar, ActivityBarEvent, IActivityBarItem } from 'mo/index';
import { ExtensionService } from 'mo/services/extensionService';

function initActivityBar(extensionCtx: ExtensionService) {
Expand Down
3 changes: 1 addition & 2 deletions src/extensions/explore/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from 'react';
import { ActivityBarEvent, IActivityBarItem } from 'mo/core/workbench/activityBar';
import { activityBar, sidebar } from 'mo/index';
import { activityBar, ActivityBarEvent, IActivityBarItem, sidebar } from 'mo/index';

import { Explorer } from './explore';
import { ExtensionService } from 'mo/services/extensionService';
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ export * from 'mo/services';
export * from 'mo/provider';
export * from 'mo/workbench';
export * from 'mo/common/event';
export * from 'mo/core';
57 changes: 0 additions & 57 deletions src/services/activityBarService.ts

This file was deleted.

9 changes: 7 additions & 2 deletions src/services/baseService.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
export abstract class BaseService {
import { EventService } from './eventService';

export abstract class BaseService<S = any> {
public abstract getState(): S;
/**
* Subscribe the service event
* @param name Event name
* @param callback Callback function
*/
public abstract subscribe(name: string | string [], callback: Function);
public subscribe(name: string | string [], callback: Function) {
EventService.subscribe(name, callback);
}
}
55 changes: 0 additions & 55 deletions src/services/editor/editorService.ts

This file was deleted.

30 changes: 0 additions & 30 deletions src/services/editor/groupService.ts

This file was deleted.

21 changes: 12 additions & 9 deletions src/services/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import 'reflect-metadata';
export * from './eventService';
export * from './activityBarService';
export * from './workbench/activityBarService';
export * from './eventService';
export * from './extensionService';
export * from './menuBarService';
export * from './sidebarService';
export * from './workbench/menuBarService';
export * from './workbench/sidebarService';
export * from './themeService';
export * from './moleculeService';
export * from './editor/editorService';
export * from './workbench/editorService';
export * from './stateService';
export * from './workbench/statusBarService';

import { container } from 'tsyringe';
import { ActivityBarService } from './activityBarService';
import { ActivityBarService } from './workbench/activityBarService';
import { ExtensionService } from './extensionService';
import { SidebarService } from './sidebarService';
import { MenuBarService } from './menuBarService';
import { SidebarService } from './workbench/sidebarService';
import { MenuBarService } from './workbench/menuBarService';
import { ThemeService } from './themeService';
import { EditorService } from './editor/editorService';
import { EditorService } from './workbench/editorService';
import { StatusBarService } from './workbench/statusBarService';

/**
* The Services of Workbench
Expand All @@ -25,6 +26,7 @@ const activityBar = container.resolve(ActivityBarService);
const sidebar = container.resolve(SidebarService);
const menuBar = container.resolve(MenuBarService);
const editor = container.resolve(EditorService);
const statusBar = container.resolve(StatusBarService);

/**
* The theme service,
Expand All @@ -42,6 +44,7 @@ export {
activityBar,
sidebar,
menuBar,
statusBar,
editor,
extension,
theme,
Expand Down
37 changes: 0 additions & 37 deletions src/services/menuBarService.ts

This file was deleted.

50 changes: 0 additions & 50 deletions src/services/moleculeService.ts

This file was deleted.

31 changes: 0 additions & 31 deletions src/services/sidebarService.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/services/stateService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function mapState<S>(WrappedComponent: React.ComponentType<any>, state: S
constructor(props) {
super(props);
this.onChange = this.onChange.bind(this);
this.state = cloneInstance(state);
this.state = state;
}

componentDidMount() {
Expand Down

0 comments on commit 6ccd70c

Please sign in to comment.