|
@@ -1,6 +1,10 @@
|
|
// Copyright (c) Jupyter Development Team.
|
|
// Copyright (c) Jupyter Development Team.
|
|
// Distributed under the terms of the Modified BSD License.
|
|
// Distributed under the terms of the Modified BSD License.
|
|
|
|
|
|
|
|
+import {
|
|
|
|
+ IIterator
|
|
|
|
+} from 'phosphor/lib/algorithm/iteration';
|
|
|
|
+
|
|
import {
|
|
import {
|
|
ISequence
|
|
ISequence
|
|
} from 'phosphor/lib/algorithm/sequence';
|
|
} from 'phosphor/lib/algorithm/sequence';
|
|
@@ -18,7 +22,11 @@ import {
|
|
} from 'phosphor/lib/collections/vector';
|
|
} from 'phosphor/lib/collections/vector';
|
|
|
|
|
|
import {
|
|
import {
|
|
- defineSignal, ISignal
|
|
|
|
|
|
+ IDisposable
|
|
|
|
+} from 'phosphor/lib/core/disposable';
|
|
|
|
+
|
|
|
|
+import {
|
|
|
|
+ clearSignalData, defineSignal, ISignal
|
|
} from 'phosphor/lib/core/signaling';
|
|
} from 'phosphor/lib/core/signaling';
|
|
|
|
|
|
|
|
|
|
@@ -117,7 +125,7 @@ interface IListChangedArgs<T> {
|
|
* A sequence container which can be observed for changes.
|
|
* A sequence container which can be observed for changes.
|
|
*/
|
|
*/
|
|
export
|
|
export
|
|
-interface IObservableList<T> {
|
|
|
|
|
|
+interface IObservableList<T> extends IDisposable {
|
|
/**
|
|
/**
|
|
* A signal emitted when the list has changed.
|
|
* A signal emitted when the list has changed.
|
|
*/
|
|
*/
|
|
@@ -133,6 +141,13 @@ interface IObservableList<T> {
|
|
*/
|
|
*/
|
|
readonly items: ISequence<T>;
|
|
readonly items: ISequence<T>;
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Create an iterator over the values in the list.
|
|
|
|
+ *
|
|
|
|
+ * @returns A new iterator starting at the front of the list.
|
|
|
|
+ */
|
|
|
|
+ iter(): IIterator<T>;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Get the item at a specific index in the list.
|
|
* Get the item at a specific index in the list.
|
|
*
|
|
*
|
|
@@ -277,6 +292,34 @@ class ObservableList<T> implements IObservableList<T> {
|
|
return this.internal;
|
|
return this.internal;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Test whether the list has been disposed.
|
|
|
|
+ */
|
|
|
|
+ get isDisposed(): boolean {
|
|
|
|
+ return this._isDisposed;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Dispose of the resources held by the list.
|
|
|
|
+ */
|
|
|
|
+ dispose(): void {
|
|
|
|
+ if (this.isDisposed) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this._isDisposed = true;
|
|
|
|
+ clearSignalData(this);
|
|
|
|
+ this.internal.clear();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Create an iterator over the values in the list.
|
|
|
|
+ *
|
|
|
|
+ * @returns A new iterator starting at the front of the list.
|
|
|
|
+ */
|
|
|
|
+ iter(): IIterator<T> {
|
|
|
|
+ return this.internal.iter();
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Get the item at a specific index in the list.
|
|
* Get the item at a specific index in the list.
|
|
*
|
|
*
|