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
govuk_publishing_components-17.8.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.7.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.6.1 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.6.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.5.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.4.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.3.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.2.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.1.1 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.1.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-17.0.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-16.29.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-16.28.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-16.27.1 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-16.27.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-16.26.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-16.25.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-16.24.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-16.23.0 node_modules/rxjs/src/scheduler/QueueAction.ts
govuk_publishing_components-16.22.0 node_modules/rxjs/src/scheduler/QueueAction.ts