Redux action tools.
- License:
- Apache-2.0
- Source:
Members
(inner, constant) payload
Unique, private identifier distinguishing between EmptyAction and PayloadAction (statically and in runtime).
Methods
(inner) actionCreators(actionEnum, payloadCreators)
Construct action slice for provided action enum. Optionally define action creators with payload. Statically typed.
Parameters:
Name | Type | Description |
---|---|---|
actionEnum |
Enum upon which an ActionCreators object is built. |
|
payloadCreators |
Optional object with payload creators. |
Returns:
ActionCreators object.
(inner) bindActionCreator(actionCreator, dispatch)
Binds given action creator with chosen store's dispatch.
Parameters:
Name | Type | Description |
---|---|---|
actionCreator |
any action creator |
|
dispatch |
redux store's |
Returns:
bound action creator
(inner) bindActionCreators(actionCreators, dispatch)
Redux's original bindActionCreators
clone with extended Action
support (original function assumes dispatch parametrized with redux's
AnyAction
which is not compatible with Action
).
Turns an object with action creators into an object with every
action creator wrapped into a dispatch
call.
Parameters:
Name | Type | Description |
---|---|---|
actionCreators |
Object with action creator functions |
|
dispatch |
redux store's |
Returns:
Object with wrapped action creators
(inner) bindActionCreatorsTree(acTree, dispatch)
Bind whole tree of action creators to the redux's dispatch function.
Parameters:
Name | Type | Description |
---|---|---|
acTree |
Object with |
|
dispatch |
redux store's |
Returns:
Object with wrapped action creators
(inner) createReducer(initState) → {ReduxBoundReducer}
Create clean and readable reducers for redux.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
initState |
Returns:
- Type:
-
ReduxBoundReducer
(inner) defineActionCreator()
Action creator not carrying anything else than just type
field.
(inner) emptyActionCreators(actionEnum)
Construct object whose keys correspond to actionEnum
keys and
values consists of empty action creators for each type. Conforms to
EmptyActionCreators<ActionEnum>
interface.
Parameters:
Name | Type | Description |
---|---|---|
actionEnum |
Enum upon which an EmptyActionCreators object is built. |
Returns:
EmptyActionCreators object.
(inner) isNumberActionType()
Type predicate - is a given action of number type?
(inner) isStringActionType()
Type predicate - is a given action of string type?
(inner) isWithPayload()
Type predicate - does a given action carry payload?
(inner) payloadActionCreators(emptyActionCreators, payloadCreators)
Take empty action creators object based on ActionEnum
type
(an object with all action creators not carrying anything besides
type
property) and PayloadCreators
object consisting of plain
javascript functions taking arguments and returning values.
PayloadCreators
object type is constrained to be a subset of ActionEnum
type (in the sense of AllowSubset
type defined in type/utils.ts
).
Create fully typed action creators object with all action creators
defined as EmptyActionCreator
or PayloadActionCreator
.
Parameters:
Name | Type | Description |
---|---|---|
emptyActionCreators |
EmptyActionCreators object |
|
payloadCreators |
Object with payload creators. |
Returns:
ActionCreators object.
(inner) sliceReducer(initState)
Statically typed reducer for a slice of state.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
initState |
Returns:
(builder: (slice: SliceBuildAPI) => void) => ReduxCompatReducer