also whats the general consensus on MVP vs MVVM + ...
# android
n
also whats the general consensus on MVP vs MVVM + data-binding?
k
like an official consensus?
g
There is no consensus. Use what is better for you. Actually even with data-binding you can use Presenters and it’s good practice. This is some kind of official position, but not a rule:

https://youtu.be/Ts-uxYiBEQ8?list=PLOU2XLYxmsIJz-cYWfjQP8SV7n8C-PTVm&t=545

My IMHO that data-binding library is great and helps a lot, you just need some rules like “do not leak context to ViewModel”, “keep ViewModel clean” etc. But it removes a lot of code and make your code more testable, much less pain and boilerplate code comparing with MVP
🎖️ 1
s
@gildor is there a starter-project to see the idiomatic usage of Architecture Components with Rx and Dagger ? Have been struggling to see how they fit together
g
But Dagger and Rx don’t have anything related, I don’t see how they should fit
Architecture Components is a set of libraries, depending on what you want to use
s
well - its not fit together in the hard sense, but more on how they are layered together and used. All of these are not just plain libraries, but also a way of thinking about structure - and that's where im stuck. (if that makes sense ?)
g
Dagger is just DI framework, you can use it almost with any library and I don’t see any incompatibilities. And yes, it’s one of layers of your app that does dependency injection and gives you inversion of control, nothing related to RxJava, Room or any other library
Architecture Components is not one library, depending on your case Room has RxJava2 support out of the box RxLifecycle provides adapter for AC Lifecycle, if you want to use it for resource managing LiveData is of course some kind light reactive library but with very specific domain. You can check video, that I posted above, they have a few words how do they see LiveData and Rx work in the same app, of course if you have Rx
So I think your question is too abstract to answer on it. I just don’t see any specific issues. If you need RxJava just use it, if you don’t need, don’t use Same for Dagger or any other library
s
well my question comes off like that because we have a large legacy codebase that already uses Dagger and RxJava. So we are beginning by asking the question "how should we refactor it". That's why my question is more around "how do these libraries fit together". For a person beginning a new project, you are right - your answer makes perfect sense
g
how should we refactor it
Dagger and RxJava fit perfectly, because they responsible for completely different things If you have problems with your legacy code, I think you should solve those problems, instead of replacing one library with another or thinking about possible library incompatibility, especially if they already in your code
You can replace some parts written on RxJava with LiveData, but only some of them, and you actually need real reason for that
s
im kind of not asking what to replace it with - my doubt came from the introduction of viewmodels. so I see lots of newer articles on the web about how rxjava and viewmodels work together, so was kind of unsure on how these things work together. so i was hoping there was kind of a nice starter project with all of these components which i can see and learn from.
for example - take a look at this thread and see how many people dispute the right patterns. so i was wondering what does the kotlin community think of it. https://github.com/googlesamples/android-architecture/issues/138
g
This thread about very particular architecture: MVVM with RxJava, without databindings. It’s one of possible ways, same as many others. I know people who use it, but personally don’t like this, MVVM based on databindings looks better for me
And I don’t see anything related to Kotlin in this particular discussion about architecture approach
s
some others would refuse to do it this way and highly recommend Anko. I dont see any problem in asking this from a kotlin perspective.
g
Anko is just way to build UI, you can use any architecture with it
s
a lot of people say that Anko is not fairly current - and is lagging quite a bit. what do you think ?
g
I don’t use Anko, I’m fine with xml, especially with DataBinding
s
thanks ! that was useful info.
g
But not sure about lagging, because it’s just a way to build view hierarchy, and it should be faster, then xml inflating (that uses reflections), after View hierarchy creation I don’t think that any difference between anko, xml or view creation from code without dsl
d
I use thirtyinch mvp lib, make all ui components into obsevables in the view, and all model functions return observables (singles or completables), then use the presenter as a glue to subscribe to view actions and model results and set view set as a result...