I never understood why a lot of this was never handled with metaprogramming. I feel like it might have something to do with Redux using constants and imports as a type safety hack, but all the ceremony drives me nuts.
First we enumerate our actions as constants...
const ADD_TODO = 'ADD_TODO'
Then we need to create an "action creator" somewhere:
import { ADD_TODO } from '../actionTypes'
function addTodo(text) {
return {
type: ADD_TODO,
text
}
}
Then we need to import that action and dispatch it when we need it...
import addTodo from './actions'
dispatch(addTodo(text))
First we enumerate our actions as constants...
Then we need to create an "action creator" somewhere: Then we need to import that action and dispatch it when we need it... Now even the same nonsense for reducers...