Browse Source

Change session kernel changed signal to be a real IChangedArgs signal.

Jason Grout 5 years ago
parent
commit
a287b4f9ab

+ 15 - 2
packages/apputils/src/clientsession.tsx

@@ -1,7 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { PathExt } from '@jupyterlab/coreutils';
+import { PathExt, IChangedArgs } from '@jupyterlab/coreutils';
 
 import { UUID } from '@phosphor/coreutils';
 
@@ -43,7 +43,20 @@ export interface IClientSession extends IDisposable {
   /**
    * A signal emitted when the kernel changes.
    */
-  readonly kernelChanged: ISignal<this, Session.IKernelChangedArgs>;
+  readonly sessionChanged: ISignal<
+    this,
+    IChangedArgs<Session.ISession | null, 'session'>
+  >;
+
+  session: Session.ISession | null;
+
+  /**
+   * A signal emitted when the kernel changes.
+   */
+  readonly kernelChanged: ISignal<
+    this,
+    IChangedArgs<Kernel.IKernelConnection | null, 'kernel'>
+  >;
 
   /**
    * A signal emitted when the kernel status changes.

+ 2 - 1
packages/console/src/widget.ts

@@ -133,7 +133,8 @@ export class CodeConsole extends Widget {
       session: this.session
     });
 
-    this._onKernelChanged();
+    void this._onKernelChanged();
+
     this.session.kernelChanged.connect(this._onKernelChanged, this);
     this.session.statusChanged.connect(this._onKernelStatusChanged, this);
   }

+ 1 - 1
packages/services/src/session/default.ts

@@ -198,7 +198,7 @@ export class DefaultSession implements Session.ISession {
       this.setupKernel(model.kernel);
       let newValue = this._kernel;
       oldValue.dispose();
-      this._kernelChanged.emit({ oldValue, newValue });
+      this._kernelChanged.emit({ name: 'kernel', oldValue, newValue });
     }
 
     this._handleModelChange(oldModel);

+ 20 - 9
packages/services/src/session/session.ts

@@ -14,6 +14,7 @@ import { Kernel, KernelMessage } from '../kernel';
 import { ServerConnection } from '..';
 
 import { DefaultSession } from './default';
+import { IChangedArgs } from '@jupyterlab/coreutils';
 
 /**
  * A namespace for session interfaces and factory functions.
@@ -30,10 +31,18 @@ export namespace Session {
    * convenience.
    */
   export interface ISession extends IObservableDisposable {
+    /**
+     * A signal emitted when a session property changes.
+     */
+    readonly propertyChanged: ISignal<this, 'path' | 'name' | 'type'>;
+
     /**
      * A signal emitted when the kernel changes.
      */
-    kernelChanged: ISignal<this, IKernelChangedArgs>;
+    kernelChanged: ISignal<
+      this,
+      IChangedArgs<Kernel.IKernelConnection, 'kernel'>
+    >;
 
     /**
      * The kernel statusChanged signal, proxied from the current kernel.
@@ -46,11 +55,6 @@ export namespace Session {
      */
     connectionStatusChanged: ISignal<this, Kernel.ConnectionStatus>;
 
-    /**
-     * A signal emitted when a session property changes.
-     */
-    readonly propertyChanged: ISignal<this, 'path' | 'name' | 'type'>;
-
     /**
      * The kernel iopubMessage signal, proxied from the current kernel.
      */
@@ -105,7 +109,7 @@ export namespace Session {
      * A number of kernel signals are proxied through the session from
      * whatever the current kernel is for convenience.
      */
-    readonly kernel: Kernel.IKernelConnection;
+    readonly kernel: Kernel.IKernelConnection | null;
 
     /**
      * Change the session path.
@@ -143,7 +147,7 @@ export namespace Session {
      */
     changeKernel(
       options: Partial<Kernel.IModel>
-    ): Promise<Kernel.IKernelConnection>;
+    ): Promise<Kernel.IKernelConnection | null>;
 
     /**
      * Kill the kernel and shutdown the session.
@@ -351,11 +355,18 @@ export namespace Session {
   /**
    * An arguments object for the kernel changed signal.
    */
-  export interface IKernelChangedArgs {
+  export interface IKernelChangedArgs
+    extends IChangedArgs<Kernel.IKernelConnection | null> {
+    /**
+     * The property name
+     */
+    name: 'kernel';
+
     /**
      * The old kernel.
      */
     oldValue: Kernel.IKernelConnection | null;
+
     /**
      * The new kernel.
      */