import { Observable } from 'rxjs'; import { Query } from './query'; export type EffectResult = Readonly<{ event: Event; result: Value; }>; export type EffectErrorOrigin = 'source' | 'handler'; export type EffectError = Readonly<{ origin: 'source'; event?: undefined; error: any; } | { origin: 'handler'; event: Event; error: ErrorType; }>; export type EffectNotification = Readonly<({ type: 'result'; } & EffectResult) | ({ type: 'error'; } & EffectError)>; /** * Details about performing the effect. */ export type EffectState = Readonly<{ /** Provides a result of successful execution of the handler */ result$: Observable; /** Provides a source event and a result of successful execution of the handler */ done$: Observable>; /** Provides an error emitter by a source (`event` is `undefined`) * or by the handler (`event` is not `undefined`) */ error$: Observable>; /** Provides a notification after execution of the handler for both success or error result */ final$: Observable>; /** Provides `true` if there is any execution of the handler in progress */ pending: Query; /** Provides a count of the handler in progress */ pendingCount: Query; }>;