Closed Guang1234567 closed 6 years ago
firstOrError()
returns a Single
which means it will only emit one item. Converting it to an Observable with toObservable()
will not convert it into a "hot" observable. If you want changes on database to propagate to your View layer and want a memory cache, you could look for something like PublishSubject
or PublishRelay
which is both an Observer and Observable. i.e it can listen to changes in database, store them in cache and relay them on to the View layer.
This doesn't seem to be a SQLBrite related question
I would recommend using https://github.com/JakeWharton/RxReplayingShare which will share the latest value to any new subscriber synchronously and then attach to the existing query for future updates.
@shaishavgandhi05
@JakeWharton
Thank you for your valuable advice.
@JakeWharton
Althought using RxReplayingShare, but
Query.run()
everytime after rotate the display because startWith
operator in
Do you have any idea to avoid this redundant Query.run()
after rotate the display?
No. It shouldn't matter because at worst it re-queries the cached information and at best you get updated results.
On Tue, Mar 13, 2018 at 4:36 AM GuangGuang notifications@github.com wrote:
@JakeWharton https://github.com/jakewharton
Althought using RxReplayingShare https://github.com/JakeWharton/RxReplayingShare, but
Query.run() everytime after rotate the display because startWith operator in
Do you have any idea to avoid this redundant Query.run() after rotate the display?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/square/sqlbrite/issues/240#issuecomment-372586581, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEERlE7rC6a_eoz52gexBh9bZpsEQjks5td4TcgaJpZM4Sl-mK .
Hello dev:
How to implement memory cache if using
BriteDatabase.createQuery
? Could you give me some suggestion?My code is below, but it does not working (I using cancat operator)
In addition,
MainRepository.createQueryListsItems(100L)
must receive change event after Database was modified byBriteDatabase.insert(...)