-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updating an element in a observable list #150
Comments
So rethinking this question, it appears quite obvious with streams that I must update the array and update Subject with the next data item. However a clarification on I also wondered if we could use BehaviorSubject instead of Subject? might be useful. |
However I would like to know if we can use
|
Hi @sbitproz Thanks for your kind words and for your interest in this library. Also, sorry that it took me a while to get back to you, I'm trying to take a break during these days 🙂 This is a very interesting question. As you already know, there are many different ways to accomplish this and using a One thing to take into account, though, is that one of the purposes of this library is to help at avoiding memory-leaks. Meaning that if the library is used as it's intended, if a stream stops having subscribers then its state gets disposed. This section of the docs tries to explain this a bit better. However, if we were using I hope that this answers your question. PS: I've seen that you have opened another issue. I don't have time right now to look at it, but I check it out as soon as I have a chance: probably in the next few days or so 🙂 |
Hi @josepot Totally grateful for message, on new years day no less... I like the way you've approached the solution with streams. I've applied your Although I understand that I freely admit, it maybe be down to my lack of understanding of what's going on under the hood. You have answered my question and I've read most of the library documentation, just wanted to soundboard the idea ( |
This library wants to promote a mental model where we avoid mutating state directly, because the we want to be able to define the dynamic behavior of the state at the time of its declaration. Therefore, if we adhere to this mental model, then we should try to use Subjects only for capturing external events, not as a means for mutating the state. This is indeed a quite radical mental-shift, but based in our experience, this mental model ends-up generating code that's less complex and easier to maintain. I'm going to close this issue, because as you said, I have already answered your question. However, feel free to keep commenting on it after it's closed. Thanks! |
Thank you for this awesome library.
Reviewing your example https://react-rxjs.org/docs/tutorial/github-issues I can see that there's a good example of requesting a list of items form
https://api.github.com/repos/${org}/${repo}/issues?per_page=25&page=${page}
.currentRepoAndPage$
is a merge of 2 source observablescurrentRepo$
andpageSelected$
. When any of these source Subjects emit a new valuewill re-execute.
The question; if I had an observable with a list of issues and I wanted to update one of the issues in the list, what would this look like? Would I update the item in the list from the component and call a function to push the new list into the
Subject
?I also wondered if we could use
BehaviorSubject
instead ofSubject
?The text was updated successfully, but these errors were encountered: