Skip to content
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

Merged
merged 3 commits into from Jan 18, 2016

Conversation

jaggernod
Copy link
Collaborator

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.

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.
@apoi
Copy link
Collaborator

apoi commented Jan 11, 2016

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.
@jaggernod
Copy link
Collaborator Author

@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 + ')'))
Copy link
Collaborator

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@apoi
Copy link
Collaborator

apoi commented Jan 17, 2016

@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.

@jaggernod
Copy link
Collaborator Author

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.

apoi added a commit that referenced this pull request Jan 18, 2016
Replaced Map of Subjects with a single subject
@apoi apoi merged commit 77e92a8 into master Jan 18, 2016
@apoi apoi deleted the fix/improved-performance branch January 21, 2016 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants