sockeqwe / mosby

A Model-View-Presenter / Model-View-Intent library for modern Android apps
http://hannesdorfmann.com/mosby/
Apache License 2.0
5.49k stars 841 forks source link

Contradiction to the Clean architecture principles #301

Closed tseglevskiy closed 6 years ago

tseglevskiy commented 6 years ago

I'm trying to split the app to layer according Clean architecture principles. As I understand these principles, layer with presenters should know nothing about what kind of UI we use. So I created module for that layer as Java library (not Android library). After that I realized that I can not set observation of view state in main thread, because presented has no access to android-specific libraries (yet), but method in view don't manage its thread (too late to do it there).

https://github.com/sockeqwe/mosby/blob/master/sample-mvi/src/main/java/com/hannesdorfmann/mosby3/sample/mvi/view/home/HomePresenter.java#L88

So my question - possible the good place to manage the thread is in the MVI framework, nor in the presenter?

tseglevskiy commented 6 years ago

Small update. I thought about this a little. Possible requirement of schedulers in layer with presenters and controllers is not an issue: any code can manage their multithreading. And that mechanics often is OS-dependent. So I create thread manager and provide it to upper layers.

Anyway, I'd like to listen your comments.

Also I see another issue. The Mosby MVI library brings to layer with presenters lots of Android-specific libraries. I'd like to have Mosby in two parts: first one will contain interfaces for presenters and views, and I can use it in layer with presenters, second one will contain implementation of framework, and it will be safe in Android-specific layer.

What do you think?

tseglevskiy commented 6 years ago

Oh, you already did it. I reread tree of dependencies and found the mvi-common module. It is exactly what I ask. So now my layer with presenters is clean. Thank you. :)

sockeqwe commented 6 years ago

So this can be closed, right?

If not, feel free to reopen it