Rx: StorIOContentResolver updates running on StorIOContentResolverNotificationsThread
See original GitHub issueHello,
I’ve noticed that when using the StorIOContentResolver
API, all emissions triggered by a contentResolver notifications come back on the same thread, so doing a long running operation on the same observable can delay notifications being received by another listener. For instance:
PreparedGetListOfObjects<> query = storIOSQLite
.get()
.listOfObjects(Tweet.class)
.withQuery(TweetsTable.query)
.prepare()
Subscription subA = query.asRxObservable()
.doOnNext(tweets -> Log.d("TEST", "Logs immediately!"))
.flatMap(tweets -> lonRunningObservable()) /* Say this runs for 10 seconds */
.subscribe()
Subscription subB = query.asRxObservable()
/* Delayed if notification was delivered to subscriber A*/
.doOnNext(tweets -> Log.d("TEST", "Sometimes logs 10 seconds late!"))
.subscribe()
...
final List<Tweet> tweets = new ArrayList<Tweet>();
tweets.add(Tweet.newTweet("artem_zin", "Cool Tweet"));
storIOSQLite
.put()
.objects(tweets)
.prepare()
.asRxObservable()
.subscribe();
I realize that it can be avoided by switching to another thread with observeOn()
, but aren’t updates supposed to use the default (or specified) scheduler?
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
pushtorefresh/storio: Reactive API for SQLiteDatabase and ...
Flowable from Get Operation will observe changes in StorIO ( SQLite or ContentProvider ) and receive updates automatically; StorIO is replacements for ...
Read more >ContentResolver | Android Developers
An extension of ContentResolver that is designed for testing. ... to indicate that this notification is the result of an ContentProvider#update call.
Read more >070: An honest discussion about Realm - Fragmented Podcast
In this episode they have an honest and frank discussion about using Realm, the advantages, the disadvantages, the gotchas and if it makes...
Read more >Does `context.contentResolver.query()` run on UI thread?
I am working on a application to get call logs, I am finding it hard to find if context.contentResolver.query() runs on UI thread...
Read more >awesome-java - CD2H gitForager
Description: A curated list of awesome Java frameworks, libraries and software. Created: 2015-08-12 17:56:04.0. Updated: 2018-05-21 00:08:30.0.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@geralt-encore what do you think about proposal?
Since we should initially receive all notifications on the common handler thread (https://github.com/pushtorefresh/storio/blob/master/storio-content-resolver/src/main/java/com/pushtorefresh/storio/contentresolver/impl/RxChangesObserver.java#L40) moving emission to thread from io pool will add delay due to thread switching =( If user will agree with such delay
defaultObserveOnScheduler(Schedulers.io())
will do this trick If you prefer to manually configure schedulers on every case and get rid of such delay - simply usedefaultObserveOnScheduler(null)
I’m not sure that
asRxObservable(Scheduler)
will give more benefits overasRxObservable().observerOn(Scheduler)