Closed luisatmaniak closed 7 years ago
Right now there are a few possibilities:
You could add the UUID at the place where you create that action.
You could also have a middleware that adds it.
Another option is to make another function that calls that action creator:
const addTodo = actionCreator<{name: string, id: string}>('ADD_TODO')
const createAddTodo = (payload: {name: string}) => addTodo({...payload, id: uuid.v4()})
Then use it to create actions, but use original addTodo
in reducers.
Thanks for answering. Yes, that seems like a good solution, it's a bit painful to have to export two actions creators (one for actually creating the action another one for .case(..)
in fsa-reducers), but besides that, I think this will work.
Thank again.
I agree that it's not as beautiful as it could be. I'm open for API proposals if you have one.
How could I do something like the following in typescript-fsa?
I know the type is added automatically and all, but I want to be able to augment/modify the passed payload, is this possible? I'd also like to preserve composability with typescript-fsa-reducers.