actionTypes
There are a few action types that Zedux uses internally. While there should never be any reason for you to use these types, you may see them show up in your inspectors. They are listed here for your information.
Properties
HYDRATE
Zedux dispatches this action when the store's .hydrate()
method is called.
The hydrate action's payload
property will be the value of the new state. Thus a store's inspectors can be notified of otherwise unserializable "actions". The idea here is that dispatching an hydrate action is exactly equivalent to calling store.hydrate()
.
For example, dispatching the following inducer:
store.dispatch(() => 'new state')
is exactly equivalent to dispatching the following hydrate action:
store.dispatch({
type: '@@zedux/hydrate',
payload: 'new state'
})
In short, this action makes time travel possible even when using store.hydrate()
.
Usage
import { actionTypes } from 'zedux'
const { HYDRATE } = actionTypes
PARTIAL_HYDRATE
Zedux dispatches this action in two scenarios:
When the store's
setState()
method is called.When an inducer is dispatched to the store.
Behavior is very similar to the HYDRATE action. The only difference being that the PARTIAL_HYDRATE action's payload
is a partial state update that should be merged into the existing state, whereas a HYDRATE action's payload replaces the state entirely.
In short, this action makes time travel possible even when using inducers and store.setState()
.
RECALCULATE
Zedux dispatches this action to the store when the store's reactor hierarchy is changed via store.use()
. As such, this is the action that typically calculates the initial state of the store.
Usage
import { actionTypes } from 'zedux'
const { RECALCULATE } = actionTypes