Ver Fonte

#refresh() should return a promise.

Afshin Darian há 6 anos atrás
pai
commit
efb14f6c09

+ 2 - 2
packages/coreutils/src/poll.ts

@@ -169,14 +169,14 @@ export class Poll<T = any, U = any> implements IDisposable {
   /**
    * Refresh the poll.
    */
-  refresh(): this {
+  refresh(): Promise<this> {
     this._schedule({
       interval: 0,
       payload: null,
       phase: 'override',
       tick: new Date().getTime()
     });
-    return this;
+    return this.next;
   }
 
   /**

+ 1 - 12
packages/services/src/terminal/manager.ts

@@ -30,24 +30,13 @@ export class TerminalManager implements TerminalSession.IManager {
 
       // Start polling with exponential backoff.
       this._pollModels = new Poll({
-        factory: state => {
-          // console.log('generating poll promise...', state);
-          return this._refreshRunning();
-        },
+        factory: () => this._refreshRunning(),
         interval: 10 * 1000,
         max: 300 * 1000,
         min: 100,
         name: `@jupyterlab/services:TerminalManager#models`,
         when: this._readyPromise
       });
-      const handle = (poll: Poll) => {
-        console.log(`#next`, poll.state);
-        poll.next.then(handle);
-      };
-      this._pollModels.next.then(handle);
-      this._pollModels.ticked.connect(sender => {
-        console.warn(`#ticked`, sender.state);
-      });
     }
   }