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
Replaced Map of Subjects with a single subject #99
Conversation
Map of subjects had an issue with a race condition. Additionally already created subjects were never cleaned. Replacing them with a single subject ensures that when a subscriber finishes the subscrition is being disposed. Keeping all the logic handling in a single monad makes sure that all race conditions are handeled properly.
Something breaks with this PR. When testing with RxGitHubApp, the repository can be changed only once, a second repo change has no effect on the UI. |
Unwillingly passing onComplete from queryOne to the subjectCache and, therefore, stopping the cache.
@apoi I have amended the PR. Found the problem. Can you please check? |
queryOne(uri).subscribe(t -> subjectMap.get(uri).onNext(t)); | ||
} | ||
queryOne(uri) | ||
.doOnNext(item -> Log.v(TAG, "onChange(" + uri + ')')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big deal, but I'm not a fan of combining " and '. It just doesn't look consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@jaggernod, verified, this works now and the code looks good. We should try to get some unit testing for these internals too, especially since GitHub restricts the frequency of API calls which basically breaks intensive manual testing. |
Yes, you are right with the unit tests. I was even thinking of refactoring the SingleItemContentProviderStore to inject ContentObserver, but then the amount of work would get out of the scope of the PR. Need to dedicate a separate PR to that. And from now on looking at testability more would be a nice thing to do. |
Replaced Map of Subjects with a single subject
Map of subjects had an issue with a race condition.
Additionally already created subjects were never cleaned.
Replacing them with a single subject ensures that when
a subscriber finishes the subscrition is being disposed.
Keeping all the logic handling in a single monad makes sure
that all race conditions are handeled properly.