Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(editor): add the onOpenTab event #416

Merged
merged 2 commits into from
Sep 8, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(editor): add the onOpenTab event
  • Loading branch information
wewoor committed Sep 8, 2021
commit 966833346e82fd6f8b9153088bdec113cc3f5f22
11 changes: 11 additions & 0 deletions src/services/workbench/editorService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ export interface IEditorService extends Component<IEditor> {
* @param callback
*/
onUpdateTab(callback: (tab: IEditorTab) => void): void;
/**
* Listen to the tab opening event
* @param callback
*/
onOpenTab(callback: (tab: IEditorTab) => void): void;
/**
* Listen to the tab move event
* @param callback
Expand Down Expand Up @@ -562,12 +567,18 @@ export class EditorService
groups.push(group);
}

this.emit(EditorEvent.OpenTab, tab);

this.setState({
current: group,
groups: [...groups],
});
}

public onOpenTab(callback: (tab: IEditorTab) => void): void {
this.subscribe(EditorEvent.OpenTab, callback);
}

public closeAll(groupId: number) {
const { current, groups = [] } = this.state;
const groupIndex = this.getGroupIndexById(groupId);
Expand Down