About ActionObject
The recommended structure of ActionObject is:
{
type: 'target:where:what:the-operation',
payload: {
data: 'data'
}
}
Action Type
The Type of Action can be any String. It's better if the String comes with a nice Format. And it's much better when the related Information is also included.
Here's some example:
'service:cache:project'
'entry:account:valid'
'entry:prompt:auth:revoke'
'entry:external-link:register'
'reducer:config:update'
Once the Format and the Information is decided. The Action Type becomes easy to guess.
Action Payload
Put all the Action Data inside another Object is neat. You get to do something like these:
const originAction = { type: 'service:data:check', payload: { data: 'data' } }
// data repack
const { payload } = originAction
const repackAction = { type: 'service:data:set', payload }
// data merge
const { payload } = originAction
const mergeAction = { type: 'service:data:update', payload: { ...payload, add: 'add' } }
Going Further
Discard Action Creators! You know the Action Type, and where to put the Action Data. Just dispatch the Object.
The Good
No need to import the Action Creators to various depth of the project. The Type is as clear as the Action Creator name.
The Catch
The source code, and even the compiled code may be longer for the added Action Type String