import { Observable, Operator, OperatorFunction, Subject } from 'rxjs'; import * as _ngrx_store from '@ngrx/store'; import { Action, ActionCreator, Creator, Store, StoreRootModule, StoreFeatureModule } from '@ngrx/store'; import * as i0 from '@angular/core'; import { ErrorHandler, OnDestroy, Type, ModuleWithProviders, InjectionToken, EnvironmentProviders } from '@angular/core'; /** * Configures an effect created by `createEffect`. */ interface EffectConfig { /** * Determines if the action emitted by the effect is dispatched to the store. * If false, effect does not need to return type `Observable`. */ dispatch?: boolean; /** * Determines whether the functional effect will be created. * If true, the effect can be created outside the effects class. */ functional?: boolean; /** * Determines if the effect will be resubscribed to if an error occurs in the main actions stream. */ useEffectsErrorHandler?: boolean; } declare const CREATE_EFFECT_METADATA_KEY = "__@ngrx/effects_create__"; interface CreateEffectMetadata { [CREATE_EFFECT_METADATA_KEY]: EffectConfig; } interface FunctionalCreateEffectMetadata extends CreateEffectMetadata { [CREATE_EFFECT_METADATA_KEY]: EffectConfig & { functional: true; }; } type FunctionalEffect Observable = () => Observable> = Source & FunctionalCreateEffectMetadata; type EffectPropertyKey> = Exclude; type EffectsMetadata> = { [Key in EffectPropertyKey]?: EffectConfig; }; type DispatchType = T extends { dispatch: infer U; } ? U : true; type ObservableType = T extends false ? OriginalType : Action; type EffectResult = Observable | ((...args: any[]) => Observable); type ConditionallyDisallowActionCreator = DT extends false ? unknown : Result extends EffectResult ? OT extends ActionCreator ? 'ActionCreator cannot be dispatched. Did you forget to call the action creator function?' : unknown : unknown; declare function createEffect, OTP, R extends EffectResult, OT extends ObservableType>(source: () => R & ConditionallyDisallowActionCreator, config?: C): R & CreateEffectMetadata; declare function createEffect Observable>(source: Source, config: EffectConfig & { functional: true; dispatch: false; }): FunctionalEffect; declare function createEffect Observable>(source: Source & ConditionallyDisallowActionCreator>, config: EffectConfig & { functional: true; dispatch?: true; }): FunctionalEffect; declare function getEffectsMetadata>(instance: T): EffectsMetadata; interface NextNotification { kind: 'N'; value: T; } interface ErrorNotification { kind: 'E'; error: any; } interface CompleteNotification { kind: 'C'; } type ObservableNotification = NextNotification | ErrorNotification | CompleteNotification; interface EffectNotification { effect: Observable | (() => Observable); propertyName: PropertyKey; sourceName: string | null; sourceInstance: any; notification: ObservableNotification; } type EffectsErrorHandler = (observable$: Observable, errorHandler: ErrorHandler) => Observable; declare function defaultEffectsErrorHandler(observable$: Observable, errorHandler: ErrorHandler, retryAttemptLeft?: number): Observable; declare function mergeEffects(sourceInstance: any, globalErrorHandler: ErrorHandler, effectsErrorHandler: EffectsErrorHandler): Observable; declare class Actions extends Observable { constructor(source?: Observable); lift(operator: Operator): Observable; static ɵfac: i0.ɵɵFactoryDeclaration, never>; static ɵprov: i0.ɵɵInjectableDeclaration>; } type ActionExtractor, E> = T extends string ? E : ReturnType>; declare function ofType[], U extends Action = Action, V = ReturnType>(...allowedTypes: AC): OperatorFunction; declare function ofType, AC extends ActionCreator, T1 extends string | AC, U extends Action = Action, V = T1 extends string ? E : ReturnType>>(t1: T1): OperatorFunction; declare function ofType, AC extends ActionCreator, T1 extends string | AC, T2 extends string | AC, U extends Action = Action, V = ActionExtractor>(t1: T1, t2: T2): OperatorFunction; declare function ofType, AC extends ActionCreator, T1 extends string | AC, T2 extends string | AC, T3 extends string | AC, U extends Action = Action, V = ActionExtractor>(t1: T1, t2: T2, t3: T3): OperatorFunction; declare function ofType, AC extends ActionCreator, T1 extends string | AC, T2 extends string | AC, T3 extends string | AC, T4 extends string | AC, U extends Action = Action, V = ActionExtractor>(t1: T1, t2: T2, t3: T3, t4: T4): OperatorFunction; declare function ofType, AC extends ActionCreator, T1 extends string | AC, T2 extends string | AC, T3 extends string | AC, T4 extends string | AC, T5 extends string | AC, U extends Action = Action, V = ActionExtractor>(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5): OperatorFunction; /** * Fallback for more than 5 arguments. * There is no inference, so the return type is the same as the input - * Observable. * * We provide a type parameter, even though TS will not infer it from the * arguments, to preserve backwards compatibility with old versions of ngrx. */ declare function ofType(...allowedTypes: Array>): OperatorFunction; declare class EffectSources extends Subject { private errorHandler; private effectsErrorHandler; constructor(errorHandler: ErrorHandler, effectsErrorHandler: EffectsErrorHandler); addEffects(effectSourceInstance: any): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare class EffectsRunner implements OnDestroy { private effectSources; private store; private effectsSubscription; get isStarted(): boolean; constructor(effectSources: EffectSources, store: Store); start(): void; ngOnDestroy(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare class EffectsRootModule { private sources; constructor(sources: EffectSources, runner: EffectsRunner, store: Store, rootEffectsInstances: unknown[], storeRootModule: StoreRootModule, storeFeatureModule: StoreFeatureModule, guard: unknown); addEffects(effectsInstance: unknown): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } declare class EffectsFeatureModule { constructor(effectsRootModule: EffectsRootModule, effectsInstanceGroups: unknown[][], storeRootModule: StoreRootModule, storeFeatureModule: StoreFeatureModule); static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } declare class EffectsModule { static forFeature(featureEffects: Array | Record>): ModuleWithProviders; static forFeature(...featureEffects: Array | Record>): ModuleWithProviders; static forRoot(rootEffects: Array | Record>): ModuleWithProviders; static forRoot(...rootEffects: Array | Record>): ModuleWithProviders; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } declare const ROOT_EFFECTS_INIT = "@ngrx/effects/init"; declare const rootEffectsInit: _ngrx_store.ActionCreator<"@ngrx/effects/init", () => _ngrx_store.Action<"@ngrx/effects/init">>; declare const USER_PROVIDED_EFFECTS: InjectionToken<(Type | InjectionToken)[][]>; declare const EFFECTS_ERROR_HANDLER: InjectionToken; /** * @description * Interface to set an identifier for effect instances. * * By default, each Effects class is registered * once regardless of how many times the Effect class * is loaded. By implementing this interface, you define * a unique identifier to register an Effects class instance * multiple times. * * @usageNotes * * ### Set an identifier for an Effects class * * ```ts * class EffectWithIdentifier implements OnIdentifyEffects { * constructor(private effectIdentifier: string) {} * * ngrxOnIdentifyEffects() { * return this.effectIdentifier; * } * * ``` */ declare interface OnIdentifyEffects { /** * @description * String identifier to differentiate effect instances. */ ngrxOnIdentifyEffects(): string; } /** * @description * Interface to control the lifecycle of effects. * * By default, effects are merged and subscribed to the store. Implement the OnRunEffects interface to control the lifecycle of the resolved effects. * * @usageNotes * * ### Implement the OnRunEffects interface on an Effects class * * ```ts * export class UserEffects implements OnRunEffects { * constructor(private actions$: Actions) {} * * ngrxOnRunEffects(resolvedEffects$: Observable) { * return this.actions$.pipe( * ofType('LOGGED_IN'), * exhaustMap(() => * resolvedEffects$.pipe( * takeUntil(this.actions$.pipe(ofType('LOGGED_OUT'))) * ) * ) * ); * } * } * ``` */ declare interface OnRunEffects { /** * @description * Method to control the lifecycle of effects. */ ngrxOnRunEffects(resolvedEffects$: Observable): Observable; } /** * @description * Interface to dispatch an action after effect registration. * * Implement this interface to dispatch a custom action after * the effect has been added. You can listen to this action * in the rest of the application to execute something after * the effect is registered. * * @usageNotes * * ### Set an identifier for an Effects class * * ```ts * class EffectWithInitAction implements OnInitEffects { * ngrxOnInitEffects() { * return { type: '[EffectWithInitAction] Init' }; * } * ``` */ declare interface OnInitEffects { /** * @description * Action to be dispatched after the effect is registered. */ ngrxOnInitEffects(): Action; } /** * Runs the provided effects. * Can be called at the root and feature levels. */ declare function provideEffects(effects: Array | Record>): EnvironmentProviders; /** * Runs the provided effects. * Can be called at the root and feature levels. */ declare function provideEffects(...effects: Array | Record>): EnvironmentProviders; export { Actions, EFFECTS_ERROR_HANDLER, EffectSources, EffectsFeatureModule, EffectsModule, EffectsRootModule, EffectsRunner, ROOT_EFFECTS_INIT, USER_PROVIDED_EFFECTS, createEffect, defaultEffectsErrorHandler, getEffectsMetadata, mergeEffects, ofType, provideEffects, rootEffectsInit }; export type { CreateEffectMetadata, EffectConfig, EffectNotification, EffectsErrorHandler, EffectsMetadata, FunctionalEffect, OnIdentifyEffects, OnInitEffects, OnRunEffects };