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
One action is under the guard, other two need an additional data from different stores to perform a side effect. This is quite simplified case, when parameters of startDrivingEvent and startDrivingRequestFx is matching, and you don no need to create an additional sample/guards/attach.
But even in this example i found the code is a bit bloated, and found that with .watch it could be much shorter and readable (because you see all control flow in one place)
The difference become more noticable when you have switch cases, together with guards and other control-flow operations.
So the question is there any drawbacks of using .watch in above mentioned cases and when i should use sample/guard/split/etc instead of watch? I'm asking because all examples using declarative approach and it making a perception that i trying to use watch for something that it not designed to use.
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'm a new to Effector and trying to not make bad decisions in the begining.
Let's look into the simple case.
When an event is dispatched we should do a three other actions (side-effects):
One action is under the guard, other two need an additional data from different stores to perform a side effect. This is quite simplified case, when parameters of startDrivingEvent and startDrivingRequestFx is matching, and you don no need to create an additional sample/guards/attach.
But even in this example i found the code is a bit bloated, and found that with
.watch
it could be much shorter and readable (because you see all control flow in one place)The difference become more noticable when you have switch cases, together with guards and other control-flow operations.
So the question is there any drawbacks of using
.watch
in above mentioned cases and when i should use sample/guard/split/etc instead of watch? I'm asking because all examples using declarative approach and it making a perception that i trying to use watch for something that it not designed to use.Beta Was this translation helpful? Give feedback.
All reactions