RFC: Add "createActionGroup" function to Store package #3337
Replies: 8 comments 1 reply
-
Yes please!! |
Beta Was this translation helpful? Give feedback.
-
Hi, to me the syntax looks not really shortened. Pros
Cons
Other thoughts
|
Beta Was this translation helpful? Give feedback.
-
I really love the suggestion! The great advantage would be the standardization on the consumer side, eg before some consumers imported individual actions while others chose to namespace it using With the proposal, consumption of actions could be standardized across all consumers 👍👍👍 |
Beta Was this translation helpful? Give feedback.
-
In order to encourage a better action hygiene, I would see the following possible:
which in devtools would result in actions like |
Beta Was this translation helpful? Give feedback.
-
I'd go with the following signature: export const AuthApiActions = createActionGroup({
source: 'Auth API',
events: {
'Login Success': props<{ userId: string; token: string }>(),
'Login Failure': props<{ error: string }>(),
'Logout Success': emptyProps(),
'Logout Failure': (error: Error) => ({ error }),
},
}); |
Beta Was this translation helpful? Give feedback.
-
I like the design. As @tomastrajan said, it will standardize the way people refer to action in different codebase. But the mapping between the name and the function is harder to read. Well detailed action's description like ' Load User, Todo List And Assignees ' won't be advised. |
Beta Was this translation helpful? Give feedback.
-
Does that mean that it would replace createAction method or just be added ? For the sake of standard, it would be better to replace, but that would be a massive job of migration for some apps. |
Beta Was this translation helpful? Give feedback.
-
#3381 has landed, so locking this conversation in favor of issues for future bugs/features |
Beta Was this translation helpful? Give feedback.
-
Long ago, Mike Ryan proposed an API for creating a group of actions with a single function. Today if you're using NgRx Store, you define a set of actions as:
This API would shorten the syntax to:
Reference Tweet: https://twitter.com/MikeRyanDev/status/1308209467834671104
TypeScript Playground: https://bit.ly/2Hb6r2s
Beta Was this translation helpful? Give feedback.
All reactions