UNPKG

@equinor/fusion-observable

Version:
25 lines (24 loc) 1.24 kB
import type { FlowSubject } from '../FlowSubject'; import type { Action, Effect, ActionType, ExtractAction } from '../types'; /** * React hook that attaches a side-effect to a {@link FlowSubject}, filtered * by a specific action type. * * @template S - The state type. * @template A - The action type. * @template TType - The specific action type to listen for. * @param subject - The `FlowSubject` to attach the effect to. * @param type - The action type string to filter on. * @param effect - The effect function invoked for each matching action. */ export declare function useObservableEffect<S, A extends Action = Action, TType extends ActionType<A> = ActionType<A>>(subject: FlowSubject<S, A>, type: TType, effect?: Effect<ExtractAction<A, TType>, S>): void; /** * React hook that attaches a side-effect to a {@link FlowSubject} for all actions. * * @template S - The state type. * @template A - The action type. * @param subject - The `FlowSubject` to attach the effect to. * @param effect - The effect function invoked for each dispatched action. */ export declare function useObservableEffect<S, A extends Action = Action>(subject: FlowSubject<S, A>, effect: Effect<A, S>): void; export default useObservableEffect;