import { Observable, OperatorFunction, Subscription } from 'rxjs'; import { Action } from './action'; import { Controller } from './controller'; import { EffectState } from './effectState'; import { Query } from './query'; /** * Handler for an event. It can be asynchronous. * * @result a result, Promise or Observable */ export type EffectHandler = (event: Event) => Result | Promise | Observable; export type EffectEventProject = (event: Event) => Observable; export type EffectPipeline = (eventProject: EffectEventProject) => OperatorFunction; export type EffectOptions = Readonly<{ /** * Custom pipeline for processing effect's events. * * `mergeMap` pipeline is used by default. */ pipeline?: EffectPipeline; }>; /** * Effect encapsulates a handler for Action or Observable. * * It provides the state of execution results, which can be used to construct * a graph of business logic. * * Effect collects all internal subscriptions, and provides `destroy()` methods * unsubscribe from them and deactivate the effect. */ export type Effect = Controller & { handle: (source: Action | Observable | Query) => Subscription; }>; /** * Creates `Effect` from the provided handler. * * @example * ```ts * const sumEffect = createEffect<{a: number, b: number}, number>((event) => { * return a + b; * }); * ``` */ export declare function createEffect(handler: EffectHandler, options?: EffectOptions): Effect;