realm/realm-android-adapters

How to know when RealmResults changed?

demogorgorn opened this issue · 1 comments

Should we use in activity/fragment RealmResult listener or we can do this using adapter. My case is to ypdate internal counters when item was added to realm.

Hi @demogorgorn
These sorts of questions are better suited for Stack Overflow that also has a bigger community for answering.

But you want to add a RealmChangeListener to your RealmResults. This is e.g. what our RealmRecyclerViewAdapter does: https://github.com/realm/realm-android-adapters/blob/master/adapters/src/main/java/io/realm/RealmRecyclerViewAdapter.java#L181

If you do it inside an activity or inside an adapter is really up to you as it depends a lot on the use case and general archicture of your app.