-
Hi guys, first off, I want to say I love this library and the way it integrates with React. I was reading and doing some tests using the Todo App provided by the docs, and I'm trying to make the application start with some todos loaded from an API call, but I don't think the way I did here is it right. It doesn't fell right calling .subscribe mannualy from state file. The getUsers function is inside api folder. Can you guys take a look at this or suggest to me what would be the better way of doing this? https://codesandbox.io/s/react-rxjs-basic-todos-9snq9w?file=/src/api/getTodos.ts thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Hi @gleisonkz ! Thanks for your kind words. I moved the issue to the discussions section, I hope that you don't mind that. The thing is that if I were to go back in time I would have probably written that Todos demo a bit differently. Anyways, I'm a bit busy right now with some work stuff, but I will get back to you in the next hours/days with a suggestion on this... However, if I forgot to do so, then please ping me with a reminder 🙏 |
Beta Was this translation helpful? Give feedback.
-
Hi @gleisonkz ! So, yep, your intuition is right: manually calling subscribe, while also using Check this out, later today (or perhaps tomorrow) I will try to find the time to provide a better explanation of the changes that I've made in there. |
Beta Was this translation helpful? Give feedback.
-
I'm just wondering why all items in the list are being re-rendered when a item is deleted or created |
Beta Was this translation helpful? Give feedback.
Hi @gleisonkz !
So, yep, your intuition is right: manually calling subscribe, while also using
tap
for something like that should be a clear indicator that something is off. In the end the philosophy of this library is that we should be able to specify the dynamic behavior of any piece of state completely at the time of declaration. So, yep, what your code was doing is precisely what we would like to avoid doing: "poking" a setters whenever we want to change the state, because then it becomes very difficult to understand why and/or what changed a piece of state... The purpose of this library is to be able to compose different small pieces of state through streams.Check this out, later to…