Skip to content
This repository has been archived by the owner on Jan 14, 2018. It is now read-only.

RoboSpice within the MVVM pattern #471

Open
bogdanzurac opened this issue Jun 25, 2017 · 2 comments
Open

RoboSpice within the MVVM pattern #471

bogdanzurac opened this issue Jun 25, 2017 · 2 comments

Comments

@bogdanzurac
Copy link

How would RoboSpice interact within the new MVVM Architecture Components introduced at Google IO 2017? Considering we'd have a data layer consisting of repositories which fetch data from a web API and store that data inside an ORM, all of this without taking life-cycle into account and the view layer not knowing anything about the data layer (thus not being able to start/stop the SpiceManager inside Activities and Fragments).

I've tried to search the issues for relevant threads and the best I could find was this one from 3 years ago: #211

Architecture Components reference: https://developer.android.com/topic/libraries/architecture/index.html

@stephanenicolas
Copy link
Owner

stephanenicolas commented Jun 25, 2017 via email

@bogdanzurac
Copy link
Author

putting your data in a view model after a RS
request, knowing that the view model might be destroyed. That's doable, for
instance if you stop RS requests when the view model is destroyed, or just
unplug your listeners there instead of onDestroy.

True, but then we'd just move something that only the Data layer should know about (RoboSpice) from the View layer to the ViewModel layer. I strongly believe that data layer implementation specifics (that is, if we are using RS or any other caching/network mechanism, such as Room or in memory caching, etc.) should reside inside the data layer only; and not bubble up towards upper layers.

Currently, we've been using RS inside the View layer directly, which, in more complex apps, does hinder refactoring and feature changes, compared to a more clean MVVM approach.

So I guess what I'm basically asking is, if RS can be more tightly integrated into a MVVM app arch, without sacrificing its core principles (which you already mentioned, such as the foreground service approach).

PS: Yeah, I've noticed the hackish method of using retained Fragments for VMs as well :))

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants