Pārlūkot izejas kodu

Switch to using the application-wide IChangedArgs interface.

Afshin Darian 8 gadi atpakaļ
vecāks
revīzija
880cde7bf6

+ 6 - 2
src/notebook/cells/editor.ts

@@ -17,7 +17,11 @@ import {
 } from '../../codemirror/widget';
 
 import {
-  ICellModel, ICellModelChanged
+  IChangedArgs
+} from '../../common/interfaces';
+
+import {
+  ICellModel,
 } from './model';
 
 
@@ -242,7 +246,7 @@ class CellEditorWidget extends CodeMirrorWidget {
   /**
    * Handle changes in the model state.
    */
-  protected onModelStateChanged(model: ICellModel, args: ICellModelChanged): void {
+  protected onModelStateChanged(model: ICellModel, args: IChangedArgs<any>): void {
     switch (args.name) {
     case 'source':
       let doc = this.editor.getDoc();

+ 8 - 26
src/notebook/cells/model.ts

@@ -17,6 +17,10 @@ import {
   clearSignalData, defineSignal, ISignal
 } from 'phosphor/lib/core/signaling';
 
+import {
+  IChangedArgs
+} from '../../common/interfaces';
+
 import {
   IMetadataCursor, MetadataCursor
 } from '../common/metadata';
@@ -30,28 +34,6 @@ import {
 } from '../output-area';
 
 
-/**
- * The definition for cell model changes.
- */
-export
-interface ICellModelChanged {
-  /**
-   * The name of the changed attribute.
-   */
-  name: string;
-
-  /**
-   * The old value of the changed attribute.
-   */
-  oldValue: any;
-
-  /**
-   * The new value of the changed attribute.
-   */
-  newValue: any;
-}
-
-
 /**
  * The definition of a model object for a cell.
  */
@@ -73,12 +55,12 @@ interface ICellModel extends IDisposable {
   /**
    * A signal emitted when a metadata field changes.
    */
-  metadataChanged: ISignal<ICellModel, ICellModelChanged>;
+  metadataChanged: ISignal<ICellModel, IChangedArgs<any>>;
 
   /**
    * A signal emitted when a model state changes.
    */
-  stateChanged: ISignal<ICellModel, ICellModelChanged>;
+  stateChanged: ISignal<ICellModel, IChangedArgs<any>>;
 
   /**
    * The input content of the cell.
@@ -201,12 +183,12 @@ class CellModel implements ICellModel {
   /**
    * A signal emitted when a metadata field changes.
    */
-  metadataChanged: ISignal<ICellModel, ICellModelChanged>;
+  metadataChanged: ISignal<ICellModel, IChangedArgs<any>>;
 
   /**
    * A signal emitted when a model state changes.
    */
-  stateChanged: ISignal<ICellModel, ICellModelChanged>;
+  stateChanged: ISignal<ICellModel, IChangedArgs<any>>;
 
   /**
    * The input content of the cell.

+ 9 - 5
src/notebook/cells/widget.ts

@@ -25,6 +25,10 @@ import {
   loadModeByMIME
 } from '../../codemirror';
 
+import {
+  IChangedArgs
+} from '../../common/interfaces';
+
 import {
   RenderMime
 } from '../../rendermime';
@@ -42,7 +46,7 @@ import {
 } from './editor';
 
 import {
-  ICellModel, ICellModelChanged, ICodeCellModel,
+  ICellModel, ICodeCellModel,
   IMarkdownCellModel, IRawCellModel
 } from './model';
 
@@ -289,14 +293,14 @@ class BaseCellWidget extends Widget {
    * #### Notes
    * Subclasses may reimplement this method as needed.
    */
-  protected onModelStateChanged(model: ICellModel, args: ICellModelChanged): void {
+  protected onModelStateChanged(model: ICellModel, args: IChangedArgs<any>): void {
     // no-op
   }
 
   /**
    * Handle changes in the model.
    */
-  protected onMetadataChanged(model: ICellModel, args: ICellModelChanged): void {
+  protected onMetadataChanged(model: ICellModel, args: IChangedArgs<any>): void {
     switch (args.name) {
       case 'trusted':
         this._trusted = !!this._trustedCursor.getValue();
@@ -507,7 +511,7 @@ class CodeCellWidget extends BaseCellWidget {
   /**
    * Handle changes in the model.
    */
-  protected onModelStateChanged(model: ICellModel, args: ICellModelChanged): void {
+  protected onModelStateChanged(model: ICellModel, args: IChangedArgs<any>): void {
     switch (args.name) {
     case 'executionCount':
       this.setPrompt(`${(model as ICodeCellModel).executionCount}`);
@@ -521,7 +525,7 @@ class CodeCellWidget extends BaseCellWidget {
   /**
    * Handle changes in the metadata.
    */
-  protected onMetadataChanged(model: ICellModel, args: ICellModelChanged): void {
+  protected onMetadataChanged(model: ICellModel, args: IChangedArgs<any>): void {
     switch (args.name) {
     case 'collapsed':
     case 'scrolled':