浏览代码

Switch to a common/interfaces => IChangedArgs argument for use across JupyterLab.

Afshin Darian 8 年之前
父节点
当前提交
471b641a10
共有 3 个文件被更改,包括 38 次插入32 次删除
  1. 20 0
      src/common/interfaces.ts
  2. 13 9
      src/docregistry/default.ts
  3. 5 23
      src/docregistry/interfaces.ts

+ 20 - 0
src/common/interfaces.ts

@@ -0,0 +1,20 @@
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
+
+export
+interface IChangedArgs<T> {
+  /**
+   * The name of the changed attribute.
+   */
+  name: string;
+
+  /**
+   * The old value of the changed attribute.
+   */
+  oldValue: T;
+
+  /**
+   * The new value of the changed attribute.
+   */
+  newValue: T;
+}

+ 13 - 9
src/docregistry/default.ts

@@ -19,7 +19,11 @@ import {
 } from 'phosphor/lib/ui/widget';
 
 import {
-  IDocumentModel, IDocumentContext, IDocumentModelStateChange, IModelFactory,
+  IChangedArgs
+} from '../common/interfaces';
+
+import {
+  IDocumentModel, IDocumentContext, IModelFactory,
   IWidgetFactory
 } from './index';
 
@@ -36,13 +40,6 @@ class DocumentModel implements IDocumentModel {
     this._defaultLang = languagePreference || '';
   }
 
-  /**
-   * Get whether the model factory has been disposed.
-   */
-  get isDisposed(): boolean {
-    return this._isDisposed;
-  }
-
   /**
    * A signal emitted when the document content changes.
    */
@@ -51,7 +48,14 @@ class DocumentModel implements IDocumentModel {
   /**
    * A signal emitted when the document state changes.
    */
-  stateChanged: ISignal<IDocumentModel, IDocumentModelStateChange<any>>;
+  stateChanged: ISignal<IDocumentModel, IChangedArgs<any>>;
+
+  /**
+   * Get whether the model factory has been disposed.
+   */
+  get isDisposed(): boolean {
+    return this._isDisposed;
+  }
 
   /**
    * The dirty state of the document.

+ 5 - 23
src/docregistry/interfaces.ts

@@ -17,6 +17,10 @@ import {
   Widget
 } from 'phosphor/lib/ui/widget';
 
+import {
+  IChangedArgs
+} from '../common/interfaces';
+
 
 /**
  * The interface for a document model.
@@ -31,7 +35,7 @@ interface IDocumentModel extends IDisposable {
   /**
    * A signal emitted when the model state changes.
    */
-  stateChanged: ISignal<IDocumentModel, IDocumentModelStateChange<any>>;
+  stateChanged: ISignal<IDocumentModel, IChangedArgs<any>>;
 
   /**
    * The dirty state of the model.
@@ -91,28 +95,6 @@ interface IDocumentModel extends IDisposable {
 }
 
 
-/**
- * An arguments object for the `stateChanged` signal.
- */
-export
-interface IDocumentModelStateChange<T> {
-  /**
-   * The name of the attribute being changed.
-   */
-  name: string;
-
-  /**
-   * The old state value.
-   */
-  oldValue: T;
-
-  /**
-   * The new state value.
-   */
-  newValue: T;
-}
-
-
 /**
  * The document context object.
  */