UNPKG

1.54 kBTypeScriptView Raw
1import { Observable } from 'rxjs';
2import { Action, ActionCreator } from '@ngrx/store';
3import { CreateEffectMetadata, EffectConfig, EffectMetadata, FunctionalEffect } from './models';
4type DispatchType<T> = T extends {
5 dispatch: infer U;
6} ? U : true;
7type ObservableType<T, OriginalType> = T extends false ? OriginalType : Action;
8type EffectResult<OT> = Observable<OT> | ((...args: any[]) => Observable<OT>);
9type ConditionallyDisallowActionCreator<DT, Result> = DT extends false ? unknown : Result extends EffectResult<infer OT> ? OT extends ActionCreator ? 'ActionCreator cannot be dispatched. Did you forget to call the action creator function?' : unknown : unknown;
10export declare function createEffect<C extends EffectConfig & {
11 functional?: false;
12}, DT extends DispatchType<C>, OT extends ObservableType<DT, OT>, R extends EffectResult<OT>>(source: () => R & ConditionallyDisallowActionCreator<DT, R>, config?: C): R & CreateEffectMetadata;
13export declare function createEffect<Source extends () => Observable<unknown>>(source: Source, config: EffectConfig & {
14 functional: true;
15 dispatch: false;
16}): FunctionalEffect<Source>;
17export declare function createEffect<Source extends () => Observable<Action>>(source: Source & ConditionallyDisallowActionCreator<true, ReturnType<Source>>, config: EffectConfig & {
18 functional: true;
19 dispatch?: true;
20}): FunctionalEffect<Source>;
21export declare function getCreateEffectMetadata<T extends Record<keyof T, Object>>(instance: T): EffectMetadata<T>[];
22export {};