mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-15 09:06:19 +08:00
feat(editor): replace slot with rxjs subject (#10768)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { DisposableGroup, Slot } from '@blocksuite/global/slot';
|
||||
import { DisposableGroup } from '@blocksuite/global/disposable';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
import type { BlockStdScope } from '../scope/block-std-scope';
|
||||
import { LifeCycleWatcher } from './lifecycle-watcher';
|
||||
@@ -9,10 +10,10 @@ export class EditorLifeCycleExtension extends LifeCycleWatcher {
|
||||
disposables = new DisposableGroup();
|
||||
|
||||
readonly slots = {
|
||||
created: new Slot(),
|
||||
mounted: new Slot(),
|
||||
rendered: new Slot(),
|
||||
unmounted: new Slot(),
|
||||
created: new Subject<void>(),
|
||||
mounted: new Subject<void>(),
|
||||
rendered: new Subject<void>(),
|
||||
unmounted: new Subject<void>(),
|
||||
};
|
||||
|
||||
constructor(override readonly std: BlockStdScope) {
|
||||
@@ -26,22 +27,22 @@ export class EditorLifeCycleExtension extends LifeCycleWatcher {
|
||||
|
||||
override created() {
|
||||
super.created();
|
||||
this.slots.created.emit();
|
||||
this.slots.created.next();
|
||||
}
|
||||
|
||||
override mounted() {
|
||||
super.mounted();
|
||||
this.slots.mounted.emit();
|
||||
this.slots.mounted.next();
|
||||
}
|
||||
|
||||
override rendered() {
|
||||
super.rendered();
|
||||
this.slots.rendered.emit();
|
||||
this.slots.rendered.next();
|
||||
}
|
||||
|
||||
override unmounted() {
|
||||
super.unmounted();
|
||||
this.slots.unmounted.emit();
|
||||
this.slots.unmounted.next();
|
||||
|
||||
this.disposables.dispose();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Container } from '@blocksuite/global/di';
|
||||
import { DisposableGroup } from '@blocksuite/global/disposable';
|
||||
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||
import { DisposableGroup } from '@blocksuite/global/slot';
|
||||
import { Extension } from '@blocksuite/store';
|
||||
|
||||
import type { EventName, UIEventHandler } from '../event/index.js';
|
||||
@@ -109,12 +109,12 @@ export abstract class BlockService extends Extension {
|
||||
// life cycle end
|
||||
|
||||
mounted() {
|
||||
this.specSlots.mounted.emit({ service: this });
|
||||
this.specSlots.mounted.next({ service: this });
|
||||
}
|
||||
|
||||
unmounted() {
|
||||
this.dispose();
|
||||
this.specSlots.unmounted.emit({ service: this });
|
||||
this.specSlots.unmounted.next({ service: this });
|
||||
}
|
||||
// event handlers end
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user