I have set up a watcher in android with java. It works, but I would like to switch it off when I leave the fragment but I don’t know how to do that.
private RealmEventStreamAsyncTask<RealmLogEntry> watcher;
watcher = mongoDBcollection.watchAsync();
watcher.get(resultWatch -> {
if (resultWatch.isSuccess()) {
Log.v(TAG, "Event type: " +
resultWatch.get().getOperationType() + " full document: " +
resultWatch.get().getFullDocument());
} else {
Log.e(TAG, "failed to subscribe to changes in the collection with : ",
resultWatch.getError());
}
});
I think I would have to switch it off in the onDestroy method, but how?
@Override
public void onDestroyView() {
super.onDestroyView();
}