Forráskód Böngészése

Cleanup getnotebookcontent

Steven Silvester 9 éve
szülő
commit
fa1c608895
2 módosított fájl, 8 hozzáadás és 15 törlés
  1. 4 5
      example/src/index.ts
  2. 4 10
      src/notebook/notebook/serialize.ts

+ 4 - 5
example/src/index.ts

@@ -69,11 +69,10 @@ function main(): void {
       baseUrl: SERVER_URL
     }).then(session => {
       nbModel.session = session;
-      getNotebookContent(nbModel).then(content => {
-        contents.save(NOTEBOOK, {
-          type: 'notebook',
-          content
-        });
+      let content = getNotebookContent(nbModel);
+      contents.save(NOTEBOOK, {
+        type: 'notebook',
+        content
       });
     });
   });

+ 4 - 10
src/notebook/notebook/serialize.ts

@@ -139,17 +139,11 @@ function messageToModel(msg: IKernelMessage) {
  * Get the current notebook content.
  */
 export
-function getNotebookContent(nb: NotebookModel): Promise<NotebookContent> {
-  if (!nb.session) {
-    Promise.reject('No notebook session');
-  }
+function getNotebookContent(nb: NotebookModel): NotebookContent {
   let cells = getNotebookCells(nb);
-  return nb.session.kernel.kernelInfo().then(info => {
-    let name = nb.session.kernel.name;
-    let metadata = nb.metadata;
-    return { cells, metadata, nbformat: MAJOR_VERSION, 
-                     nbformat_minor: MINOR_VERSION };
-  });
+  let metadata = nb.metadata;
+  return { cells, metadata, nbformat: MAJOR_VERSION, 
+                   nbformat_minor: MINOR_VERSION };
 }