Sha256: 7c1e7feab34de5da6e0cb291fe59b9d494a597856b129455e9c4a5a99bc41283

Contents?: true

Size: 1.04 KB

Versions: 49

Compression:

Stored size: 1.04 KB

Contents

import { Subject } from './Subject';
import { Subscriber } from './Subscriber';
import { Subscription } from './Subscription';

/**
 * @class AsyncSubject<T>
 */
export class AsyncSubject<T> extends Subject<T> {
  private value: T = null;
  private hasNext: boolean = false;
  private hasCompleted: boolean = false;

  /** @deprecated internal use only */ _subscribe(subscriber: Subscriber<any>): Subscription {
    if (this.hasError) {
      subscriber.error(this.thrownError);
      return Subscription.EMPTY;
    } else if (this.hasCompleted && this.hasNext) {
      subscriber.next(this.value);
      subscriber.complete();
      return Subscription.EMPTY;
    }
    return super._subscribe(subscriber);
  }

  next(value: T): void {
    if (!this.hasCompleted) {
      this.value = value;
      this.hasNext = true;
    }
  }

  error(error: any): void {
    if (!this.hasCompleted) {
      super.error(error);
    }
  }

  complete(): void {
    this.hasCompleted = true;
    if (this.hasNext) {
      super.next(this.value);
    }
    super.complete();
  }
}

Version data entries

49 entries across 49 versions & 4 rubygems

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