Closed sylvanaar closed 6 years ago
Hey! For your case you can use action factory, which will provide equivalent result:
import { action } from 'typesafe-actions'
const changeView = (payload: number = 1) => action(CHANGE_VIEW, payload)
Is there any reason why you didn't use that?
EDIT: I'm proposing this solution first because I don't see you use the benefits from createStandardAction
factory, but if you really want to use it because reasons ;) you can always try to use map
method like here: https://github.com/piotrwitek/typesafe-actions-todo-app/blob/master/src/features/todos/actions.ts#L11
Is it good enough or you have some suggestions to improve?
PS: I'm glad you like the library!
Thanks. I think I should have read the documentation a little more! The design is way more flexible that I thought.
Thanks again!
Had you considered parameter defaults in your design?
Right now I am doing:
(payload: number = 1) => createStandardAction(CHANGE_VIEW)<number>()(payload)
But it seems like it could be improved upon so you don't have to repeat the payload type.
Thanks for the best redux action typings around!