File tree Expand file tree Collapse file tree 3 files changed +24
-4
lines changed Expand file tree Collapse file tree 3 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ import type {
2020 JSONValue ,
2121 PartialJSONValue
2222} from '@lumino/coreutils' ;
23- import type { IDisposable , IObservableDisposable } from '@lumino/disposable' ;
23+ import type { IObservableDisposable } from '@lumino/disposable' ;
2424import type { ISignal } from '@lumino/signaling' ;
2525
2626/**
@@ -44,7 +44,7 @@ export type MapChanges = Map<
4444/**
4545 * ISharedBase defines common operations that can be performed on any shared object.
4646 */
47- export interface ISharedBase extends IDisposable {
47+ export interface ISharedBase extends IObservableDisposable {
4848 /**
4949 * Undo an operation.
5050 */
@@ -387,8 +387,7 @@ export namespace SharedCell {
387387 */
388388export interface ISharedBaseCell <
389389 Metadata extends nbformat . IBaseCellMetadata = nbformat . IBaseCellMetadata
390- > extends ISharedText ,
391- IObservableDisposable {
390+ > extends ISharedText {
392391 /**
393392 * The type of the cell.
394393 */
Original file line number Diff line number Diff line change @@ -92,6 +92,13 @@ export class YDocument<T extends DocumentChange> implements ISharedDocument {
9292 return this . _changed ;
9393 }
9494
95+ /**
96+ * A signal emitted when the document is disposed.
97+ */
98+ get disposed ( ) : ISignal < this, void > {
99+ return this . _disposed ;
100+ }
101+
95102 /**
96103 * Whether the document is disposed or not.
97104 */
@@ -132,6 +139,7 @@ export class YDocument<T extends DocumentChange> implements ISharedDocument {
132139 this . awareness . destroy ( ) ;
133140 this . undoManager . destroy ( ) ;
134141 this . ydoc . destroy ( ) ;
142+ this . _disposed . emit ( ) ;
135143 Signal . clearData ( this ) ;
136144 }
137145
@@ -209,6 +217,7 @@ export class YDocument<T extends DocumentChange> implements ISharedDocument {
209217
210218 protected _changed = new Signal < this, T > ( this ) ;
211219 private _isDisposed = false ;
220+ private _disposed = new Signal < this, void > ( this ) ;
212221}
213222
214223/**
Original file line number Diff line number Diff line change @@ -13,6 +13,18 @@ describe('@jupyter/ydoc', () => {
1313 } ) ;
1414 } ) ;
1515
16+ describe ( '#disposed' , ( ) => {
17+ test ( 'should be emitted when the document is disposed' , ( ) => {
18+ const notebook = new YNotebook ( ) ;
19+ let disposed = false ;
20+ notebook . disposed . connect ( ( ) => {
21+ disposed = true ;
22+ } ) ;
23+ notebook . dispose ( ) ;
24+ expect ( disposed ) . toEqual ( true ) ;
25+ } ) ;
26+ } ) ;
27+
1628 describe ( 'metadata' , ( ) => {
1729 test ( 'should get metadata' , ( ) => {
1830 const notebook = new YNotebook ( ) ;
You can’t perform that action at this time.
0 commit comments