You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I often define a state using discriminated union type. When using whole state in template it is straightforward since if provide correct type inference.
However I am not sure how to deal with selectors. I think about defining state as nullable for other states but I am not sure if it is the best solution since it need another if in order to check for null values which whould not be possible according to state.
but it makes impossible state possible.
Another solution I thought of was to not use selectors at all but rather pure state + e.g. pipes in order to manipulate data.
Is there a better solution for this kind of problems?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I often define a state using discriminated union type. When using whole state in template it is straightforward since
if
provide correct type inference.However I am not sure how to deal with selectors. I think about defining state as nullable for other states but I am not sure if it is the best solution since it need another
if
in order to check for null values which whould not be possible according to state.Alternative approach for it is to not define state as discriminated union type but rather something like
but it makes impossible state possible.
Another solution I thought of was to not use selectors at all but rather pure state + e.g. pipes in order to manipulate data.
Is there a better solution for this kind of problems?
Beta Was this translation helpful? Give feedback.
All reactions