ReducerBuilder
Types
Cases
type
Cases =
{
[
string
]
:
Reducer
}
Matchers
type
Matchers =
{
{
matcher:
(
Action
)
→
boolean
,
reducer:
Reducer
}
}
Functions
addCase
ReducerBuilder:
addCase
(
action:
ActionCreator
|
string
,
--
The action creator or type name
reducer:
Reducer
) →
(
)
Adds a case reducer. Can only be called before addMatcher
and
addDefaultCase
.
Case reducers are reducers that handle one type of action. They are the standard way of writing reducers in Rodux.
addMatcher
ReducerBuilder:
addMatcher
(
matcher:
(
action:
Action
)
→
boolean
,
reducer:
Reducer
) →
(
)
Adds a matcher. Cannot be called after addDefaultCase
.
Matchers can be used to handle actions based on your own custom logic rather than only matching the type.
addDefaultCase
ReducerBuilder:
addDefaultCase
(
reducer:
Reducer
) →
(
)
Adds a fallback reducer. This will be invoked if no case reducers or matchers were executed for an action.
After adding a default case you cannot modify the reducer anymore, so this should be reserved for the very last part of the chain.