import { InteropObservable, Observable, OperatorFunction, Subject } from 'rxjs'; import { UnknownAction, UnknownActionCreator, UnknownActionCreatorWithPayload, VoidPayload } from './internal/types'; export type Reducer = (previousState: State, payload: Payload, namespace?: string) => State; export type RegisteredReducer = Reducer & { trigger: { actions: UnknownActionCreator[]; } | { source$: Observable; }; }; type ObservableLike = Observable | InteropObservable; type ReducerCreator = { /** * Define a reducer for a stream * * @see combineReducers * @param source$ The stream which will trigger this reducer * @param reducer The reducer function * @template `State` - The state the reducer reduces to * @template `Payload` - The type of values `source$` emits * @returns A registered reducer that can be passed into `combineReducers`, or * called directly as if it was the `reducer` parameter itself. */ (source$: ObservableLike, reducer: Reducer): RegisteredReducer; /** * Define a reducer for multiple actions with overlapping payload * * @see combineReducers * @param actionCreator The action creator to assign this reducer to and * extract payload type from * @param reducer The reducer function * @template `State` - The state the reducer reduces to * @template `Payload` - The payload of the action, fed to the reducer together * with the state. Should be automatically extracted from * the `actionCreator` parameter * @returns A registered reducer that can be passed into `combineReducers`, or * called directly as if it was the `reducer` parameter itself. */ (actionCreator: UnknownActionCreatorWithPayload[], reducer: Reducer): RegisteredReducer; /** * Define a reducer for multiple actions without overlapping payload * * @see combineReducers * @param actionCreator The action creator to assign this reducer to and * extract payload type from * @param reducer The reducer function * @template `State` - The state the reducer reduces to * @returns A registered reducer that can be passed into `combineReducers`, or * called directly as if it was the `reducer` parameter itself. */ (actionCreator: UnknownActionCreatorWithPayload[], reducer: Reducer): RegisteredReducer; /** * Define a reducer for multiple actions without payloads * * @see combineReducers * @param actionCreator The action creator to assign this reducer to and * extract payload type from * @param reducer The reducer function * @template `State` - The state the reducer reduces to * @returns A registered reducer that can be passed into `combineReducers`, or * called directly as if it was the `reducer` parameter itself. */ (actionCreator: UnknownActionCreator[], reducer: Reducer): RegisteredReducer; /** * Define a reducer for an action with payload * * @see combineReducers * @param actionCreator The action creator to assign this reducer to and * extract payload type from * @param reducer The reducer function * @template `State` - The state the reducer reduces to * @template `Payload` - The payload of the action, fed to the reducer together * with the state. Should be automatically extracted from * the `actionCreator` parameter * @returns A registered reducer that can be passed into `combineReducers`, or * called directly as if it was the `reducer` parameter itself. */ (actionCreator: UnknownActionCreatorWithPayload, reducer: Reducer): RegisteredReducer; /** * Define a reducer for an action without payload * * @see combineReducers * @param actionCreator The action creator to assign this reducer to and * extract payload type from * @param reducer The reducer function * @template `State` - The state the reducer reduces to * @returns A registered reducer that can be passed into `combineReducers`, or * called directly as if it was the `reducer` parameter itself. */ (actionCreator: UnknownActionCreator, reducer: Reducer): RegisteredReducer; }; export declare const reducer: ReducerCreator; type CombineReducersConfig = { errorSubject?: Subject; namespace?: string; }; /** * Combine registered reducers into a stream operator * * Each reducer will receive the previous state (or the seed if it's the first * invocation) together with the payloads of the actions of the given reducer, * or the emitted values from the stream of the given reducer. * * The behaviour is undefined if multiple reducers are registered for the same * actions. * * This operator does not change whether the stream is hot or cold. * * The order of invocation for the reducers is controlled by the rxjs operator * `merge`, which is called with all the actions first and then the source * streams in the order their reducers are defined in the `reducers` argument. * * If a reducer throws an error, it will be nexted on the error subject. If the * error subject is not explicitly set, it will default to * `defaultErrorSubject`, which will rethrow the errors globally, as uncaught * exceptions. The stream will not complete or emit any value upon an error. * * @param seed The initial input to the first reducer call * @param reducers The reducer entries that should be combined * @param namespace Namespace to pass on to the reducers. Note that this will * always be passed, regardless of namespaces of the actions. * @see rxjs.merge */ export declare const combineReducers: (seed: State, reducers: RegisteredReducer[], { errorSubject, namespace }?: CombineReducersConfig) => OperatorFunction; export {};