Replies: 1 comment
-
You function example loses |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm struggling a little bit with finding good reasons to use effects in ngrx component store.
It seems that just having a normal function would be appropriate for a lot of cases and also has some other advantages.
For example I can do:
or I can do:
The advantages of using an
effect
are supposed to be:but points 2 and 3 are often not relevant.
Like in this example, I'm likely calling
loadUsers()
imperatively once in a componentngOnInit
.Because of this the whole reactivity feels more like something we wanted to make happen, rather than needed to happen.
Big disadvantage of going the
effect
route is that it's more complicated.There's more nesting. It's not immediately obvious how a synchronous call to
loadUser
results in something being pushed to input observable, especially if it's a stream of voids.On a number of occasions I've seen people being confused about this.
I've seen people write an effect like this, which is incorrect, but ironically works for this case:
Right now I'm trying to decide between doubling down on effects or mixing two approaches.
Beta Was this translation helpful? Give feedback.
All reactions