Options
Menu

Class AsyncSystem<Query, Data, Error>

AsyncSystem is a reactive storage System, to store, replay and wait for simple async tasks.

An AsyncSystem is a systematic combination of four Units. one each for every aspect of an asynchronous task or API,
e.g.: XHR, fetch or a third party abstraction like Angular's HttpClient.

See https://docs.activejs.dev/fundamentals/systems/asyncsystem for more details.

Hierarchy

Constructors

Member Units Properties

Other Properties

Accessors

Access Value Methods

Common Methods

Custom AsyncSystem Methods

Other Methods

Constructors

constructor

Member Units Properties

Readonly dataUnit

dataUnit: GenericUnit<Data>

The member Unit that is intended to portray the role of response aspect of an async task.

Readonly errorUnit

errorUnit: GenericUnit<Error>

The member Unit that is intended to portray the role of error aspect of an async task.

Readonly pendingUnit

pendingUnit: BoolUnit

The member Unit that is intended to portray the role of pending-status of an async task.

Readonly queryUnit

queryUnit: GenericUnit<Query>

The member Unit that is intended to portray the role of query aspect of an async task.

Other Properties

Readonly config

config: Readonly<AsyncSystemConfig<Query, Data, Error>>

Configured options.
Combination of global-options GlobalAsyncSystemConfig and the options passed on instantiation.

Readonly events$

events$: Observable<BaseEvents<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>> | any>

On-demand observable events. See https://docs.activejs.dev/guides/events for more details.

Readonly future$

future$: Observable<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>> = this.futureSubject.asObservable()

An Observable to observe future values, unlike the default Observable it doesn't replay when subscribed to, rather it waits for the next value.

Accessors

emitCount

  • get emitCount(): number

relationshipsWorking

  • get relationshipsWorking(): boolean

Access Value Methods

value

  • value(): AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>

Common Methods

asObservable

  • asObservable(): Observable<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>>
  • Creates a new Observable using the default Observable as source. Use this to conceal other aspects of a Unit, System, Action or Cluster except the Observable part.

    Returns Observable<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>>

    An Observable with the value of a Unit, System, Action or Cluster.

createStream

  • A helper method that creates a stream by subscribing to the Observable returned by the param observableProducer callback.

    Ideally the callback function creates an Observable by applying Observable.pipe on the queryUnit or queryUnit.future$ as source Observable.

    Then, after a successful data flow, dispatch the data to the dataUnit;
    and after a failure, dispatch the error to the errorUnit, caught by using RxJS' catchError operator.

    Just know that you should catch the error in a sub-pipe (ie: do not let it propagate to the main-pipe), otherwise as usual the stream will stop working, and will not react on any further emissions.

    Type parameters

    • R

    Parameters

    Returns Stream

replay

  • replay(): void

toJsonString

  • toJsonString(): string

Custom AsyncSystem Methods

pauseRelationships

  • pauseRelationships(): void

resumeRelationships

  • resumeRelationships(): void

Other Methods

pipe

  • pipe(): Observable<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>>
  • pipe<A>(op1: OperatorFunction<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>, A>): Observable<A>
  • pipe<A, B>(op1: OperatorFunction<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>, A>, op2: OperatorFunction<A, B>): Observable<B>
  • pipe<A, B, C>(op1: OperatorFunction<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>): Observable<C>
  • pipe<A, B, C, D>(op1: OperatorFunction<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>): Observable<D>
  • pipe<A, B, C, D, E>(op1: OperatorFunction<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>): Observable<E>
  • pipe<A, B, C, D, E, F>(op1: OperatorFunction<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>): Observable<F>
  • pipe<A, B, C, D, E, F, G>(op1: OperatorFunction<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>): Observable<G>
  • pipe<A, B, C, D, E, F, G, H>(op1: OperatorFunction<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>, op8: OperatorFunction<G, H>): Observable<H>
  • pipe<A, B, C, D, E, F, G, H, I>(op1: OperatorFunction<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>, op8: OperatorFunction<G, H>, op9: OperatorFunction<H, I>): Observable<I>
  • pipe<A, B, C, D, E, F, G, H, I>(op1: OperatorFunction<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>, op8: OperatorFunction<G, H>, op9: OperatorFunction<H, I>, ...operations: OperatorFunction<any, any>[]): Observable<{}>
  • Returns Observable<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>>

  • Type parameters

    • A

    Parameters

    • op1: OperatorFunction<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>, A>

    Returns Observable<A>

  • Type parameters

    • A

    • B

    Parameters

    • op1: OperatorFunction<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>, A>
    • op2: OperatorFunction<A, B>

    Returns Observable<B>

  • Type parameters

    • A

    • B

    • C

    Parameters

    • op1: OperatorFunction<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>

    Returns Observable<C>

  • Type parameters

    • A

    • B

    • C

    • D

    Parameters

    • op1: OperatorFunction<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>
    • op4: OperatorFunction<C, D>

    Returns Observable<D>

  • Type parameters

    • A

    • B

    • C

    • D

    • E

    Parameters

    • op1: OperatorFunction<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>
    • op4: OperatorFunction<C, D>
    • op5: OperatorFunction<D, E>

    Returns Observable<E>

  • Type parameters

    • A

    • B

    • C

    • D

    • E

    • F

    Parameters

    • op1: OperatorFunction<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>
    • op4: OperatorFunction<C, D>
    • op5: OperatorFunction<D, E>
    • op6: OperatorFunction<E, F>

    Returns Observable<F>

  • Type parameters

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    Parameters

    • op1: OperatorFunction<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>
    • op4: OperatorFunction<C, D>
    • op5: OperatorFunction<D, E>
    • op6: OperatorFunction<E, F>
    • op7: OperatorFunction<F, G>

    Returns Observable<G>

  • Type parameters

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    • H

    Parameters

    • op1: OperatorFunction<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>
    • op4: OperatorFunction<C, D>
    • op5: OperatorFunction<D, E>
    • op6: OperatorFunction<E, F>
    • op7: OperatorFunction<F, G>
    • op8: OperatorFunction<G, H>

    Returns Observable<H>

  • Type parameters

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    • H

    • I

    Parameters

    • op1: OperatorFunction<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>
    • op4: OperatorFunction<C, D>
    • op5: OperatorFunction<D, E>
    • op6: OperatorFunction<E, F>
    • op7: OperatorFunction<F, G>
    • op8: OperatorFunction<G, H>
    • op9: OperatorFunction<H, I>

    Returns Observable<I>

  • Type parameters

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    • H

    • I

    Parameters

    • op1: OperatorFunction<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>
    • op4: OperatorFunction<C, D>
    • op5: OperatorFunction<D, E>
    • op6: OperatorFunction<E, F>
    • op7: OperatorFunction<F, G>
    • op8: OperatorFunction<G, H>
    • op9: OperatorFunction<H, I>
    • Rest ...operations: OperatorFunction<any, any>[]

    Returns Observable<{}>

subscribe

  • subscribe(observer?: PartialObserver<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>>): Subscription
  • subscribe(next: null | undefined, error: null | undefined, complete: () => void): Subscription
  • subscribe(next: null | undefined, error: (error: any) => void, complete?: () => void): Subscription
  • subscribe(next: (value: AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>) => void, error: null | undefined, complete: () => void): Subscription
  • subscribe(next?: (value: AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>) => void, error?: (error: any) => void, complete?: () => void): Subscription
  • Parameters

    • Optional observer: PartialObserver<AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>>

    Returns Subscription

  • deprecated

    Use an observer instead of a complete callback

    Parameters

    • next: null | undefined
    • error: null | undefined
    • complete: () => void
        • (): void
        • Returns void

    Returns Subscription

  • deprecated

    Use an observer instead of an error callback

    Parameters

    • next: null | undefined
    • error: (error: any) => void
        • (error: any): void
        • Parameters

          • error: any

          Returns void

    • Optional complete: () => void
        • (): void
        • Returns void

    Returns Subscription

  • deprecated

    Use an observer instead of a complete callback

    Parameters

    • next: (value: AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>) => void
        • (value: AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>): void
        • Parameters

          • value: AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>

          Returns void

    • error: null | undefined
    • complete: () => void
        • (): void
        • Returns void

    Returns Subscription

  • Parameters

    • Optional next: (value: AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>) => void
        • (value: AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>): void
        • Parameters

          • value: AsyncSystemValue<UnitToValueType<QueryUnit>, UnitToValueType<DataUnit>, UnitToValueType<ErrorUnit>>

          Returns void

    • Optional error: (error: any) => void
        • (error: any): void
        • Parameters

          • error: any

          Returns void

    • Optional complete: () => void
        • (): void
        • Returns void

    Returns Subscription

toPromise

  • toPromise<T>(this: Observable<T>): Promise<T>
  • toPromise<T>(this: Observable<T>, PromiseCtor: typeof Promise): Promise<T>
  • toPromise<T>(this: Observable<T>, PromiseCtor: PromiseConstructorLike): Promise<T>
  • Type parameters

    • T

    Parameters

    • this: Observable<T>

    Returns Promise<T>

  • Type parameters

    • T

    Parameters

    • this: Observable<T>
    • PromiseCtor: typeof Promise

    Returns Promise<T>

  • Type parameters

    • T

    Parameters

    • this: Observable<T>
    • PromiseCtor: PromiseConstructorLike

    Returns Promise<T>