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 {
20
20
JSONValue ,
21
21
PartialJSONValue
22
22
} from '@lumino/coreutils' ;
23
- import type { IDisposable , IObservableDisposable } from '@lumino/disposable' ;
23
+ import type { IObservableDisposable } from '@lumino/disposable' ;
24
24
import type { ISignal } from '@lumino/signaling' ;
25
25
26
26
/**
@@ -44,7 +44,7 @@ export type MapChanges = Map<
44
44
/**
45
45
* ISharedBase defines common operations that can be performed on any shared object.
46
46
*/
47
- export interface ISharedBase extends IDisposable {
47
+ export interface ISharedBase extends IObservableDisposable {
48
48
/**
49
49
* Undo an operation.
50
50
*/
@@ -387,8 +387,7 @@ export namespace SharedCell {
387
387
*/
388
388
export interface ISharedBaseCell <
389
389
Metadata extends nbformat . IBaseCellMetadata = nbformat . IBaseCellMetadata
390
- > extends ISharedText ,
391
- IObservableDisposable {
390
+ > extends ISharedText {
392
391
/**
393
392
* The type of the cell.
394
393
*/
Original file line number Diff line number Diff line change @@ -92,6 +92,13 @@ export class YDocument<T extends DocumentChange> implements ISharedDocument {
92
92
return this . _changed ;
93
93
}
94
94
95
+ /**
96
+ * A signal emitted when the document is disposed.
97
+ */
98
+ get disposed ( ) : ISignal < this, void > {
99
+ return this . _disposed ;
100
+ }
101
+
95
102
/**
96
103
* Whether the document is disposed or not.
97
104
*/
@@ -132,6 +139,7 @@ export class YDocument<T extends DocumentChange> implements ISharedDocument {
132
139
this . awareness . destroy ( ) ;
133
140
this . undoManager . destroy ( ) ;
134
141
this . ydoc . destroy ( ) ;
142
+ this . _disposed . emit ( ) ;
135
143
Signal . clearData ( this ) ;
136
144
}
137
145
@@ -209,6 +217,7 @@ export class YDocument<T extends DocumentChange> implements ISharedDocument {
209
217
210
218
protected _changed = new Signal < this, T > ( this ) ;
211
219
private _isDisposed = false ;
220
+ private _disposed = new Signal < this, void > ( this ) ;
212
221
}
213
222
214
223
/**
Original file line number Diff line number Diff line change @@ -13,6 +13,18 @@ describe('@jupyter/ydoc', () => {
13
13
} ) ;
14
14
} ) ;
15
15
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
+
16
28
describe ( 'metadata' , ( ) => {
17
29
test ( 'should get metadata' , ( ) => {
18
30
const notebook = new YNotebook ( ) ;
You can’t perform that action at this time.
0 commit comments