Skip to content

Instantly share code, notes, and snippets.

@Zhuinden
Last active December 22, 2017 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zhuinden/c54169a8a9cd2ca26ba91ed4399849ad to your computer and use it in GitHub Desktop.
Save Zhuinden/c54169a8a9cd2ca26ba91ed4399849ad to your computer and use it in GitHub Desktop.
Monarchy 3: Managed
public class MainActivity
extends AppCompatActivity {
ManagedDogAdapter managedDogAdapter;
LiveData<Monarchy.ManagedChangeSet<RealmDog>> changes;
Observer<Monarchy.ManagedChangeSet<RealmDog>> observer =
changes -> {
managedDogAdapter.updateData(changes);
};
@BindView(R.id.recycler_view)
RecyclerView recyclerView;
@Inject
Monarchy monarchy;
@Override
protected void onCreate(Bundle savedInstanceState) {
...
managedDogAdapter = new ManagedDogAdapter();
changes = monarchy.findAllManagedWithChanges(
realm -> realm.where(RealmDog.class));
changes.observe(this, observer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment