Browse Source

Change CodeCellWidget.execute() promise type from bool to IExecuteReplyMsg.

Evan Patterson 8 years ago
parent
commit
db5d51d70e
2 changed files with 11 additions and 10 deletions
  1. 5 9
      src/notebook/cells/widget.ts
  2. 6 1
      src/notebook/notebook/actions.ts

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

@@ -2,7 +2,7 @@
 // Distributed under the terms of the Modified BSD License.
 
 import {
-  IKernel
+  IKernel, KernelMessage
 } from 'jupyter-js-services';
 
 import {
@@ -436,24 +436,20 @@ class CodeCellWidget extends BaseCellWidget {
   /**
    * Execute the cell given a kernel.
    */
-  execute(kernel: IKernel): Promise<boolean> {
+  execute(kernel: IKernel): Promise<KernelMessage.IExecuteReplyMsg> {
     let model = this.model as ICodeCellModel;
     let code = model.source;
     if (!code.trim()) {
       model.executionCount = null;
-      return Promise.resolve(true);
+      return Promise.resolve(null);
     }
     model.executionCount = null;
     this.setPrompt('*');
     this.trusted = true;
     let outputs = model.outputs;
-    return outputs.execute(code, kernel).then((reply: any) => {
+    return outputs.execute(code, kernel).then(reply => {
       model.executionCount = reply.content.execution_count;
-      if (reply.content.status !== 'ok') {
-        model.executionCount = null;
-        return false;
-      }
-      return true;
+      return reply;
     });
   }
 

+ 6 - 1
src/notebook/notebook/actions.ts

@@ -826,7 +826,12 @@ namespace Private {
       break;
     case 'code':
       if (kernel) {
-        return (widget as CodeCellWidget).execute(kernel);
+        return (widget as CodeCellWidget).execute(kernel).then(reply => {
+          if (reply)
+            return reply.content.status === 'ok';
+          else
+            return true;
+        });
       }
       (widget.model as CodeCellModel).executionCount = null;
       break;