-
Notifications
You must be signed in to change notification settings - Fork 417
Any way to reload the database and make all observables to re-query? #39
Comments
I needed the same thing, so I just exposed the triggers.
Would be great if this would be integrated in the main branch. |
As to the re-query case, you can run a query more than once so you can use something like Observable.combineLatest(queryObservable, midnightObservable, (q, m) -> q)
.subscribe(query -> /* .. */); In this instance I'm not super sure about how widespread the use of reloading helpers is. One solution would just be to replace your Observable<BriteDatabase> dbObservable = /* .. */
dbObservable.switchMap(db -> db.createQuery("SELECT * FROM table", "table"))
.subscribe(query -> /* .. */); |
By using Observable<Query> createQuery(Iterable<String> tables, String sql, String... args){
return dbObservable.switchMap(db -> db.createQuery(tables, sql, args);
} Which is a fine solution, thank you. Another idea is to provide an About the re-query, I keep thinking making If you feel the issue is closed, then it's closed for me too. |
It's actually not that easy to accept an |
Reload
SQLiteOpenHelper
and re-queryIn my app I have a import/export functionality, by importing, the SQLite database file is replaced by one on the sdcard, so I need to reload the
SQLiteOpenHelper
and then notify all theQueries
.Something like the following method would be really handy!
Or prehaps
BriteDatabase
can save aSet
of tables, filled as we query them, to be notified on a potential database reload?I guess I could make the user restart the app, but I rather not.
SQLBrite is amazing as it is very simple and allow us to get rid of loaders, and IMO notifying on tables is far better than the Uri system, thanks for creating SQLBrite!
Re-query only
Let's say my app is a calendar, I have an upcoming event list, starting by today's events.
In every event list I want to mark each yesterday's event as missed.
Then I need to reload event's
Queries
every day at 00:00.In this particular case it would make sense to make the
sendTableTrigger()
public
and call it every day.I could also use a
Observable.combineLatest
with aQuery
and aPublishSubject
and call thisSubject
every day torun
theQuery
again, but since table triggers are managed the same way, it seems simple to switchsendTableTrigger()
topublic
.To support this idea;
ContentResolver
'snotifyChange(Uri uri, null)
ispublic
.The text was updated successfully, but these errors were encountered: