RFC - New Action Handler binding API within a state #2240
Replies: 4 comments
-
My first note on the
|
Beta Was this translation helpful? Give feedback.
-
I would prefer the I liked @arturovt point of view. However, I am not sure how often we would need to extend an Action Class since they need to be unique to their context. |
Beta Was this translation helpful? Give feedback.
-
i prefer Option B, syntax feels more ngxs and is more readable to me |
Beta Was this translation helpful? Give feedback.
-
After some extensive discussions around this with the RFCs Working Group, we came to the following conclusion:
Option A in the proposal is:
So, due to the limitations in Option B, Option A seems to be the right choice here. |
Beta Was this translation helpful? Give feedback.
-
Overview
We want to discuss the options for an alternative action handler syntax within a state.
These are the guiding design goals that we would want to achieve:
We don't need to repeat the type over and over, as is the case currently.
Currently, the Action type is declared twice, once in the
@Action
decorator and again in the function argument type.Design Goal 1
This can be achieved if we have a base class for a state that exposes the functions of the context (
getState
,setState
,patchState
,dispatch
) as protected members of the base class with the correct inferred model type.Design Goal 2
This is what is up for discussion in this RFC...
We would like a clean API for binding a function that handles an action (in the context of a state) with the type of the action it is bound to.
There are two options that we have looked at:
Option A
We define a class method as the action handler and a default argument binding that binds the action type:
Option B
We have an
onAction
function that binds the action type to a handler function:(This value is saved to a protected field)
Please submit your thoughts about these two options.
Mention which one is your favorite, but please also state what you do and don't like about both options.
If you have another idea, please go ahead and propose it here too!
Beta Was this translation helpful? Give feedback.
All reactions