Skip to content

ReducerForAction not usable with current store #46

Closed
@andretietz

Description

@andretietz

There's a definition of a ReducerForAction which cannot be used in order to create a store. A suggestion could be smth like this:

/**
 * See also https://github.com/reactjs/redux/blob/master/docs/Glossary.md#reducer
 */
typealias Reducer<State> = ReducerForActionType<State, Any>

/**
 * Reducer for a particular subclass of actions.  Useful for Sealed classes &
 * exhaustive when statements.  See [reducerForActionType].
 */
typealias ReducerForActionType<TState, TAction> = (state: TState, action: TAction) -> TState

and then make sure that the store can handle the ReducerForActionType<TState, TAction>

Personally I would change this the other way around and make the reducer be the one with the defined action:

/**
 * See also https://github.com/reactjs/redux/blob/master/docs/Glossary.md#reducer
 */
typealias Reducer<State, Action> = (state: State, action: Action) -> State

/**
 * ...
 */
typealias AnonymActionReducer<State> = Reducer<State, Any>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions