Realm-java: RxJava support for finegrained notifications

Created on 2 Mar 2017  Â·  7Comments  Â·  Source: realm/realm-java

We should extend our RxJava support to also include fine-grained notifications. It would be relatively easy to expose as a Pair<RealmResults, ChangeSet>. However naming it might be a bit difficult since asObservable() is already taken.

Some suggestions:

RealmResults<Person> persons = realm.where(Person.class).findAll();
Observable<Pair<RealmResults, OrderedCollectionChangeSet>> obs;

// #1 
obs = persons.asChangeSetObservable();
// #2
obs = persons.asObservable(true); // true = fine-grained, false = standard
// #3
obs = persons.asFinegrainedObservable();
// #4
// .... others?

One thing to consider is also that we will get single object notifications in the near future #4101, which will have similar requirements.

Personally I probably favour 1. with a 2. as a close second, both could be re-used for single object notifications I think. Thoughts @realm/java ?

TODO

  • [ ] Decide on a method name
  • [ ] Add new method to RxObservableFactory interface
  • [ ] Add implementation to RealmObservableFactory class
  • [ ] Add methods to RealmList/RealmResults
  • [ ] Unit tests
First-Good-Issue T-Enhancement

All 7 comments

I'm also wondering how this enhancement affects Rx2 support

It doesn't. RxJava1 vs. RxJava2 is a separate discussion ( #3497 ). E.g. this method might just as well be RxRealm.getChangeSetObservable(realmResults) for RxJava2 support.

I vote asObservable(true) by also keeping asObservable() /without parameters/

Thinking about this. Actually 2) is not really possible since the return type will be very different:
```
Observable>
// vs.
Observable, OrderedCollectionChangeSet>

I vote 1)

Do we consider to move RxJava2 support out of realm-java as a separated project at this time?

Fixed by #5089

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yuwu picture yuwu  Â·  3Comments

AlbertVilaCalvo picture AlbertVilaCalvo  Â·  3Comments

nolanamy picture nolanamy  Â·  3Comments

wezley98 picture wezley98  Â·  3Comments

aschrijver picture aschrijver  Â·  3Comments