Преглед изворни кода

Since connected is always available, make it a public attribute instead of only passing it into the promise factory.

Afshin Darian пре 6 година
родитељ
комит
48d6747cd0
1 измењених фајлова са 8 додато и 7 уклоњено
  1. 8 7
      packages/coreutils/src/poll.ts

+ 8 - 7
packages/coreutils/src/poll.ts

@@ -82,6 +82,13 @@ export class Poll<T = any> implements IDisposable {
    */
   readonly variance: number;
 
+  /**
+   * Whether the last poll request succeeded.
+   */
+  get connected(): boolean {
+    return this._connected;
+  }
+
   /**
    * A signal emitted when the poll is disposed.
    */
@@ -175,8 +182,7 @@ export class Poll<T = any> implements IDisposable {
     }
 
     const { max, min, variance } = this;
-    const connected = this._connected;
-    const promise = this._factory({ connected, interval, schedule });
+    const promise = this._factory({ interval, schedule });
 
     promise
       .then((payload: T) => {
@@ -329,11 +335,6 @@ export namespace Poll {
    * Definition of poll state that gets passed into the poll promise factory.
    */
   export type State = {
-    /**
-     * Whether the last poll succeeded.
-     */
-    readonly connected: boolean;
-
     /**
      * The number of milliseconds that elapsed since the last poll.
      */