Sha256: 961aa361ec3da04bb0d823b6d5cbdeedf2063e00e12731a827e1ee4cc4591b18

Contents?: true

Size: 1.35 KB

Versions: 49

Compression:

Stored size: 1.35 KB

Contents

import { AsyncAction } from './AsyncAction';
import { Subscription } from '../Subscription';
import { QueueScheduler } from './QueueScheduler';

/**
 * We need this JSDoc comment for affecting ESDoc.
 * @ignore
 * @extends {Ignored}
 */
export class QueueAction<T> extends AsyncAction<T> {

  constructor(protected scheduler: QueueScheduler,
              protected work: (this: QueueAction<T>, state?: T) => void) {
    super(scheduler, work);
  }

  public schedule(state?: T, delay: number = 0): Subscription {
    if (delay > 0) {
      return super.schedule(state, delay);
    }
    this.delay = delay;
    this.state = state;
    this.scheduler.flush(this);
    return this;
  }

  public execute(state: T, delay: number): any {
    return (delay > 0 || this.closed) ?
      super.execute(state, delay) :
      this._execute(state, delay) ;
  }

  protected requestAsyncId(scheduler: QueueScheduler, id?: any, delay: number = 0): any {
    // If delay exists and is greater than 0, or if the delay is null (the
    // action wasn't rescheduled) but was originally scheduled as an async
    // action, then recycle as an async action.
    if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
      return super.requestAsyncId(scheduler, id, delay);
    }
    // Otherwise flush the scheduler starting with this action.
    return scheduler.flush(this);
  }
}

Version data entries

49 entries across 49 versions & 4 rubygems

Version Path
ilog-0.4.1 node_modules/rxjs/src/scheduler/QueueAction.ts
ilog-0.4.0 node_modules/rxjs/src/scheduler/QueueAction.ts
ilog-0.3.3 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-18.0.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.21.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.20.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.19.1 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.19.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.18.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.17.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.16.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.15.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.14.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.13.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.12.2 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.12.1 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.12.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.11.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.10.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.9.0 node_modules/rxjs/src/scheduler/QueueAction.ts