Pārlūkot izejas kodu

No floating promises in examples.

Ian Rose 6 gadi atpakaļ
vecāks
revīzija
014d999a22

+ 2 - 2
examples/cell/src/index.ts

@@ -58,7 +58,7 @@ function main(): void {
 
   // Handle the mimeType for the current kernel.
   session.kernelChanged.connect(() => {
-    session.kernel.ready.then(() => {
+    void session.kernel.ready.then(() => {
       const lang = session.kernel.info.language_info;
       const mimeType = mimeService.getMimeTypeByLanguage(lang);
       cellWidget.model.mimeType = mimeType;
@@ -67,7 +67,7 @@ function main(): void {
 
   // Start the default kernel.
   session.kernelPreference = { autoStartDefault: true };
-  session.initialize();
+  void session.initialize();
 
   // Set up a completer.
   const editor = cellWidget.editor;

+ 3 - 3
examples/console/src/index.ts

@@ -42,7 +42,7 @@ function main(): void {
   }
 
   let manager = new ServiceManager();
-  manager.ready.then(() => {
+  void manager.ready.then(() => {
     startApp(path, manager);
   });
 }
@@ -109,7 +109,7 @@ function startApp(path: string, manager: ServiceManager.IManager) {
   commands.addCommand(command, {
     label: 'Execute Prompt',
     execute: () => {
-      consolePanel.console.execute();
+      return consolePanel.console.execute();
     }
   });
   palette.addItem({ command, category });
@@ -119,7 +119,7 @@ function startApp(path: string, manager: ServiceManager.IManager) {
   commands.addCommand(command, {
     label: 'Execute Cell (forced)',
     execute: () => {
-      consolePanel.console.execute(true);
+      return consolePanel.console.execute(true);
     }
   });
   palette.addItem({ command, category });

+ 11 - 11
examples/filebrowser/src/index.ts

@@ -32,7 +32,7 @@ import { FileEditorFactory } from '@jupyterlab/fileeditor';
 
 function main(): void {
   let manager = new ServiceManager();
-  manager.ready.then(() => {
+  void manager.ready.then(() => {
     createApp(manager);
   });
 }
@@ -91,7 +91,7 @@ function createApp(manager: ServiceManager.IManager): void {
   let creator = new ToolbarButton({
     iconClassName: 'jp-AddIcon jp-Icon jp-Icon-16',
     onClick: () => {
-      docManager
+      void docManager
         .newUntitled({
           type: 'file',
           path: fbModel.path
@@ -138,13 +138,13 @@ function createApp(manager: ServiceManager.IManager): void {
     icon: 'fa fa-edit',
     mnemonic: 0,
     execute: () => {
-      fbWidget.rename();
+      return fbWidget.rename();
     }
   });
   commands.addCommand('file-save', {
     execute: () => {
       let context = docManager.contextForWidget(activeWidget);
-      context.save();
+      return context.save();
     }
   });
   commands.addCommand('file-cut', {
@@ -167,7 +167,7 @@ function createApp(manager: ServiceManager.IManager): void {
     icon: 'fa fa-remove',
     mnemonic: 0,
     execute: () => {
-      fbWidget.delete();
+      return fbWidget.delete();
     }
   });
   commands.addCommand('file-duplicate', {
@@ -175,7 +175,7 @@ function createApp(manager: ServiceManager.IManager): void {
     icon: 'fa fa-copy',
     mnemonic: 0,
     execute: () => {
-      fbWidget.duplicate();
+      return fbWidget.duplicate();
     }
   });
   commands.addCommand('file-paste', {
@@ -183,21 +183,21 @@ function createApp(manager: ServiceManager.IManager): void {
     icon: 'fa fa-paste',
     mnemonic: 0,
     execute: () => {
-      fbWidget.paste();
+      return fbWidget.paste();
     }
   });
   commands.addCommand('file-download', {
     label: 'Download',
     icon: 'fa fa-download',
     execute: () => {
-      fbWidget.download();
+      return fbWidget.download();
     }
   });
   commands.addCommand('file-shutdown-kernel', {
     label: 'Shutdown Kernel',
     icon: 'fa fa-stop-circle-o',
     execute: () => {
-      fbWidget.shutdownKernels();
+      return fbWidget.shutdownKernels();
     }
   });
   commands.addCommand('file-dialog-demo', {
@@ -210,7 +210,7 @@ function createApp(manager: ServiceManager.IManager): void {
     label: 'Info Demo',
     execute: () => {
       let msg = 'The quick brown fox jumped over the lazy dog';
-      showDialog({
+      void showDialog({
         title: 'Cool Title',
         body: msg,
         buttons: [Dialog.okButton()]
@@ -282,7 +282,7 @@ function dialogDemo(): void {
   selector.appendChild(option1);
   body.appendChild(input);
   body.appendChild(selector);
-  showDialog({
+  void showDialog({
     title: 'Create new notebook'
   });
 }

+ 6 - 3
examples/notebook/src/commands.ts

@@ -69,9 +69,9 @@ export const SetupCommands = (
   });
   commands.addCommand(cmdIds.interrupt, {
     label: 'Interrupt',
-    execute: () => {
+    execute: async () => {
       if (nbWidget.context.session.kernel) {
-        nbWidget.context.session.kernel.interrupt();
+        await nbWidget.context.session.kernel.interrupt();
       }
     }
   });
@@ -86,7 +86,10 @@ export const SetupCommands = (
   commands.addCommand(cmdIds.runAndAdvance, {
     label: 'Run and Advance',
     execute: () => {
-      NotebookActions.runAndAdvance(nbWidget.content, nbWidget.context.session);
+      return NotebookActions.runAndAdvance(
+        nbWidget.content,
+        nbWidget.context.session
+      );
     }
   });
   commands.addCommand(cmdIds.editMode, {

+ 1 - 1
examples/notebook/src/index.ts

@@ -41,7 +41,7 @@ import { SetupCommands } from './commands';
 
 function main(): void {
   let manager = new ServiceManager();
-  manager.ready.then(() => {
+  void manager.ready.then(() => {
     createApp(manager);
   });
 }

+ 2 - 2
examples/terminal/src/index.ts

@@ -16,10 +16,10 @@ function main(): void {
   let term1 = new Terminal({ theme: 'light' });
   let term2 = new Terminal({ theme: 'dark' });
 
-  TerminalSession.startNew().then(session => {
+  void TerminalSession.startNew().then(session => {
     term1.session = session;
   });
-  TerminalSession.startNew().then(session => {
+  void TerminalSession.startNew().then(session => {
     term2.session = session;
   });
 

+ 1 - 1
packages/services/examples/typescript-browser-with-output/index.ts

@@ -31,7 +31,7 @@ function main() {
   const rendermime = new RenderMimeRegistry({ initialFactories });
   const outputArea = new OutputArea({ model, rendermime });
 
-  Kernel.startNew().then(kernel => {
+  void Kernel.startNew().then(kernel => {
     outputArea.future = kernel.requestExecute({ code });
     document.getElementById('outputarea').appendChild(outputArea.node);
   });