Is using a watch an antipattern? #612
timofei-iatsenko
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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