Support `on` with multiple actions as array
Closed this issue ยท 7 comments
Can you support something like this:
on([ Bar, Foo ], (state, { type }) => [...state, type])
Thx ๐
I don't think that's possible. Why do you need it anyway?
Never mind. I hadn't noticed that you support the same functionality with on({ Bar, Foo }, ...
. Maybe you need to update README :)
Maybe you need to update README
I guess so. ๐
Supporting multiple actions in on
is something I added only in the last few days.
May I ask why supporting array is impossible please? is it related to ReturnType() can't accept an array element as argument?
It didn't say it was impossible. I said I didn't think it was possible. The reason being is that I am not aware of a tuple equivalent to the mapped types that work with objects.
https://github.com/cartant/ts-action/blob/v8.0.0/source/functions/action.ts#L56
Actually, looking at this again, I think I'm wrong and that arrays could also be supported. I'll look more closely at this later and will add support if it's possible.
Done in 8.1.0.