feat(plugin): migrate plugin runner to rxjs

This commit is contained in:
austaras
2022-07-27 16:22:05 +08:00
parent 8280cf47b9
commit 21fbadb399
19 changed files with 323 additions and 431 deletions

View File

@@ -15,7 +15,9 @@ export class FullTextSearchPlugin extends BasePlugin {
}
public override init(): void {
this.hooks.addHook(HookType.ON_SEARCH, this.handle_search, this);
this.sub.add(
this.hooks.get(HookType.ON_SEARCH).subscribe(this._handleSearch)
);
}
protected override _onRender(): void {
@@ -31,12 +33,13 @@ export class FullTextSearchPlugin extends BasePlugin {
this.#root.unmount();
// this.#root = undefined;
}
this.sub.unsubscribe();
}
private handle_search() {
private _handleSearch = () => {
this.editor.setHotKeysScope('search');
this.render_search();
}
};
private render_search() {
if (this.#root) {
this.#root.mount();