Rxjava Data From Db With Onscreen List
Solution 1:
What you're looking for is a way to create an Observer, meaning to transform DB changes events to Observable.
So you will have 2 kind of streams: One that act on the DB and changes data (update/delete) triggered upon various events (push/cloud/user clicks) , those changes will trigger DB change event, that in it's turn, will emit events on an Second stream that represent DB changes event.
Then in your UI, you can react to the changes in Rx way (responding to the stream of DB changes events).
In order to create the DB changes Observable, you need to learn about hot to create Observable from async events (can be done using Subjects, or if you are integrating with some DB and you have DB changes events, you can 'wrap' it with Observable using fromEmitter(), you can learn more about it from this blog: https://medium.com/yammer-engineering/converting-callback-async-calls-to-rxjava-ebc68bde5831#.z1cj7ayhr
Solution 2:
One way to approach it would be to put a data service between clients and the data store. Make that data service an Observable. Allow anyone who is interested in being notified when data changes to register with the data service.
Post a Comment for "Rxjava Data From Db With Onscreen List"