Open rifler opened 5 years ago
If prefix is supposed to update the resulting action type it's not trivial task and will require some complex type magic. There are some existing third-party solutions available although I'm not sure about their performance scalability.
It would be great for my tasks to have different prefixes in runtime only
@rifler ok I guess that would be quite easy to implement and could be the first step before investigating and implementing a more complex solution involving a generation of new types.
I will include this into the new API design coming for v5.0.0 #143
I am not sure what do you mean by "without types support" but this might work for you:
export const createAsyncActionNamed = <T1, T2, T3 = Error, T4 = any>(prefix: string) => createAsyncAction(
${prefix}_REQUEST
,${prefix}_SUCCESS
,${prefix}_FAILURE
,${prefix}_CANCEL
)<T1, T2, T3, T4>();
The action names are not properly typed.
@DamodarSojka it means without updating string literal types, I have updated the title
It will be soon possible to fully implement this feature with complete type-safety, something I've been waiting for for a long time.
microsoft/TypeScript#40336
Is your feature request related to a real problem or use-case?
With this feature it will be a bit easier to implement ducks in redux https://github.com/erikras/ducks-modular-redux
Describe a solution including usage in code example
Who does this impact? Who is this for?
Now I have to use two
filter
calls in epic:Describe alternatives you've considered (optional)
Additional context (optional)
example from
redux-act
: