fix: deregister stream observers on editor deinit

This commit is contained in:
Mo Bitar
2020-04-21 12:17:01 -05:00
parent 84de39375c
commit f9733f8dac
7 changed files with 318 additions and 247 deletions

View File

@@ -30,6 +30,15 @@ export class Editor {
);
}
deinit() {
this.removeStreamObserver();
(this.removeStreamObserver as any) = undefined;
this._onNoteChange = undefined;
(this.application as any) = undefined;
this._onNoteChange = undefined;
this._onNoteValueChange = undefined;
}
private async handleNoteStream(notes: SNNote[], source?: PayloadSource) {
/** Update our note object reference whenever it changes */
const matchingNote = notes.find((item) => {
@@ -63,15 +72,6 @@ export class Editor {
this.setNote(note as SNNote);
}
deinit() {
this.removeStreamObserver();
(this.removeStreamObserver as any) = undefined;
this._onNoteChange = undefined;
(this.application as any) = undefined;
this._onNoteChange = undefined;
this._onNoteValueChange = undefined;
}
/**
* Register to be notified when the editor's note changes.
*/