5

Our team is building an Android app using Kotlin (if that matters at all) by following the guidelines described by Uncle Bob (Robert Martin).

The presentation pattern we use is MVI. We have presenters that communicate with Use Cases/Interactors and convert the resulting entity objects into ViewModels, suitable for rendering by the view.

We use a reactive DB (Realm) for storage. All communication View -> Presenter is done via RxJava2 and RxBinding.

Now, for the interesting part. The reactive database allows one to listen for change via listeners or Observable. The 2nd option is really easy to use. But, I don't want to use RxJava in our UseCase/Interactors, I want them relying only on the stdlib as much as possible. Of course, we can wrap their operations in Observables and execute them on a background thread.

I've seen many implementations that use RxJava deep into their business logic. Well, isn't that just wrong? All those "operators" make you rely on them and totally disregard the power of the language you're using.

So, my question comes down to this: Is it possible to listen for changes from a reactive database without using Observables or Listeners when querying it? Are coroutines (or something else) an option here?

1 Answer 1

2

I've seen many implementations that use RxJava deep into their business logic. Well, isn't that just wrong?

It certainly doesn't follow Clean Architecture recommendations. The DB is a plugin. A DB pretending to be a queuing system is also a plug in. That should all be handled outside of your business logic so no business logic knows about it directly.

So, my question comes down to this: Is it possible to listen for changes from a reactive database without using Observables or Listeners when querying it?

Use it the way it is meant to be used. Just do that far away from your business rules.

1
  • Thanks for the quick reply! Do you have any recommendations about specific design (or patterns) around that kind of databases? Where should the notification about database model changes come from? Commented Sep 12, 2017 at 11:06

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.