浏览代码

wip updates

Steven Silvester 8 年之前
父节点
当前提交
5db776fbc3
共有 4 个文件被更改,包括 31 次插入36 次删除
  1. 21 17
      src/inspector/handler.ts
  2. 1 5
      src/inspector/inspector.ts
  3. 1 1
      src/landing/widget.ts
  4. 8 13
      src/launcher/index.ts

+ 21 - 17
src/inspector/handler.ts

@@ -10,7 +10,7 @@ import {
 } from '@phosphor/disposable';
 
 import {
-  Signal.clearData, defineSignal, ISignal
+  ISignal, Signal
 } from '@phosphor/signaling';
 
 import {
@@ -42,17 +42,23 @@ class InspectionHandler implements IDisposable, Inspector.IInspectable {
   /**
    * A signal emitted when the handler is disposed.
    */
-  readonly disposed: ISignal<InspectionHandler, void>;
+  get disposed(): ISignal<InspectionHandler, void> {
+    return this._disposed;
+  }
 
   /**
    * A signal emitted when inspector should clear all items with no history.
    */
-  readonly ephemeralCleared: ISignal<InspectionHandler, void>;
+  get ephemeralCleared(): ISignal<InspectionHandler, void> {
+    return this._ephemeralCleared;
+  }
 
   /**
    * A signal emitted when an inspector value is generated.
    */
-  readonly inspected: ISignal<InspectionHandler, Inspector.IInspectorUpdate>;
+  get inspected(): ISignal<InspectionHandler, Inspector.IInspectorUpdate> {
+    return this._inspected;
+  }
 
   /**
    * The editor widget used by the inspection handler.
@@ -71,7 +77,7 @@ class InspectionHandler implements IDisposable, Inspector.IInspectable {
     let editor = this._editor = newValue;
     if (editor) {
       // Clear ephemeral inspectors in preparation for a new editor.
-      this.ephemeralCleared.emit(void 0);
+      this._ephemeralCleared.emit(void 0);
       editor.model.value.changed.connect(this.onTextChanged, this);
     }
   }
@@ -106,7 +112,7 @@ class InspectionHandler implements IDisposable, Inspector.IInspectable {
     this._editor = null;
     this._kernel = null;
     this._rendermime = null;
-    this.disposed.emit(void 0);
+    this._disposed.emit(void 0);
     Signal.clearData(this);
   }
 
@@ -125,7 +131,7 @@ class InspectionHandler implements IDisposable, Inspector.IInspectable {
 
     // Clear hints if the new text value is empty or kernel is unavailable.
     if (!code || !this._kernel) {
-      this.inspected.emit(update);
+      this._inspected.emit(update);
       return;
     }
 
@@ -141,19 +147,19 @@ class InspectionHandler implements IDisposable, Inspector.IInspectable {
 
       // If handler has been disposed, bail.
       if (this.isDisposed) {
-        this.inspected.emit(update);
+        this._inspected.emit(update);
         return;
       }
 
       // If a newer text change has created a pending request, bail.
       if (pending !== this._pending) {
-        this.inspected.emit(update);
+        this._inspected.emit(update);
         return;
       }
 
       // Hint request failures or negative results fail silently.
       if (value.status !== 'ok' || !value.found) {
-        this.inspected.emit(update);
+        this._inspected.emit(update);
         return;
       }
 
@@ -161,7 +167,7 @@ class InspectionHandler implements IDisposable, Inspector.IInspectable {
       let trusted = true;
       let model = new MimeModel({ data, trusted });
       update.content =  this._rendermime.render(model);
-      this.inspected.emit(update);
+      this._inspected.emit(update);
     });
   }
 
@@ -169,13 +175,11 @@ class InspectionHandler implements IDisposable, Inspector.IInspectable {
   private _kernel: Kernel.IKernel = null;
   private _pending = 0;
   private _rendermime: RenderMime = null;
-}
-
+  private _disposed = new Signal<InspectionHandler, void>(this);
+  private _ephemeralCleared = new Signal<InspectionHandler, void>(this);
+  private _inspected = new Signal<InspectionHandler, Inspector.IInspectorUpdate>(this);
 
-// Define the signals for the `InspectionHandler` class.
-defineSignal(InspectionHandler.prototype, 'disposed');
-defineSignal(InspectionHandler.prototype, 'ephemeralCleared');
-defineSignal(InspectionHandler.prototype, 'inspected');
+}
 
 
 /**

+ 1 - 5
src/inspector/inspector.ts

@@ -14,13 +14,9 @@ import {
 } from '@phosphor/application';
 
 import {
-  Panel
+  Panel, TabPanel
 } from '@phosphor/widgets';
 
-import {
-  TabPanel
-} from '@phosphor/widgettabpanel';
-
 import {
   Widget
 } from '@phosphor/widgets';

+ 1 - 1
src/landing/widget.ts

@@ -176,7 +176,7 @@ class LandingModel extends VDomModel {
    */
   set path(value: string) {
     this._path = value;
-    this.stateChanged.emit(void 0);
+    this.triggerChange();
   }
 
   private _path: string;

+ 8 - 13
src/launcher/index.ts

@@ -2,17 +2,13 @@
 // Distributed under the terms of the Modified BSD License.
 
 import {
-  IIterator, map, toArray
+  ArrayExt, ArrayIterator, IIterator, map, toArray
 } from '@phosphor/algorithm';
 
 import {
   JSONObject
 } from '@phosphor/coreutils';
 
-import {
-  Vector
-} from 'phosphor/lib/collections/vector';
-
 import {
   DisposableDelegate, IDisposable
 } from '@phosphor/disposable';
@@ -165,7 +161,6 @@ class LauncherModel extends VDomModel implements ILauncher {
    */
   constructor() {
     super();
-    this._items = new Vector<ILauncherItem>();
   }
 
   /**
@@ -179,7 +174,7 @@ class LauncherModel extends VDomModel implements ILauncher {
       return;
     }
     this._path = path;
-    this.stateChanged.emit(void 0);
+    this.triggerChange();
   }
 
   /**
@@ -200,12 +195,12 @@ class LauncherModel extends VDomModel implements ILauncher {
     item.imgClassName = item.imgClassName ||
       `jp-Image${item.name.replace(/\ /g, '')}`;
 
-    this._items.pushBack(item);
-    this.stateChanged.emit(void 0);
+    this._items.push(item);
+    this.triggerChange();
 
     return new DisposableDelegate(() => {
-      this._items.remove(item);
-      this.stateChanged.emit(void 0);
+      ArrayExt.removeFirstOf(this._items, item);
+      this.triggerChange();
     });
   }
 
@@ -213,10 +208,10 @@ class LauncherModel extends VDomModel implements ILauncher {
    * Return an iterator of launcher items.
    */
   items(): IIterator<ILauncherItem> {
-    return this._items.iter();
+    return new ArrayIterator(this._items);
   }
 
-  private _items: Vector<ILauncherItem> = null;
+  private _items: ILauncherItem[] = [];
   private _path: string = 'home';
 }