Type alias Effect<Input, Result, Error>

Effect<Input, Result, Error>: ((input: Input, args: {
    previousInput: Input | NoValueType;
    previousResult: SafeEffectResult<Result, Error> | NoValueType;
    store: Store;
}) => Observable<EffectResult<Result, Error>>)

Type Parameters

  • Input

    specifies the input type for the effect

  • Result

    specifies the result type for the effect

  • Error = unknown

    specifies the error type for the effect. Specify never, if the effect cannot error.

Type declaration

    • (input: Input, args: {
          previousInput: Input | NoValueType;
          previousResult: SafeEffectResult<Result, Error> | NoValueType;
          store: Store;
      }): Observable<EffectResult<Result, Error>>
    • The Effect<Input> type specifies a potentially impure function that takes an input and a Store as arguments and returns an effectful result as Observable<Result>. It is the low-level abstraction used by rx-signals for side-effect isolation. The high-level abstraction EffectSignalsFactory takes an EffectId as configuration to access the corresponding Effect. The args can be used to access additional input from the store (thus, the Effect itself could also be pure and just use something impure that was put into the store, e.g. another Effect), as well as the previousInput and previousResult. The previousInput can be used e.g. to decide whether the effect must perform a computation/query/etc., or if maybe the previousResult can be returned directly. If the effect cannot error, use never as Error type. In that case, EffectResult<Result, Error> will equal Result.

      Parameters

      • input: Input
      • args: {
            previousInput: Input | NoValueType;
            previousResult: SafeEffectResult<Result, Error> | NoValueType;
            store: Store;
        }
        • previousInput: Input | NoValueType

          the input of the previous function invocation, or NO_VALUE

        • previousResult: SafeEffectResult<Result, Error> | NoValueType

          SafeEffectResult instead of EffectResult, to give consumers the option to provide unhandled errors

        • store: Store

          the Store instance that will be passed to the function (e.g. to inject some other Effect)

      Returns Observable<EffectResult<Result, Error>>

Generated using TypeDoc