Open dbof10 opened 7 years ago
Scoping is about how to manage dependencies scope using dagger. Basically, we should have a singleton Store
in each scope.
I'll consider your suggestion about Epic
. Thanks for your comment
After looking thoughtfully at the architecture, I want to say something.
ViewModel
seems useless in this case? Why not bind the View
directly to the Store
?. I suggest to rename ViewModel
to something else. ViewModel
reflects exactly the Model
on the View
. I look at Uber code public abstract class LearnDetailViewModel extends ViewModel {
public static LearnDetailViewModel create(List) { ... }
public abstract List getArticles() { ... }
abstract LearnDetailViewModel setArticles(List) { ... }
}
public class LearnArticleViewModel extends ViewModel {
public String getContentUrl() { ... }
public String getImageUrl() { ... }
public String getPreview() { ... }
public List getTags() { ... }
public String getTitle() { ... }
}
int the View
public class HeroTextView extends LinearLayout {
private final ImagePartView a;
private final TextView b;
private final TextView c;
public volatile void setViewModel(ViewModel vm) {
a.setImage(vm.getImage());
}
}
Any ideas?
Reducer
is optional
, right?Hope we can make it better
A very simple and common pattern is (loading-content-error). How should you design your ViewModel
. In my point of view that ViewModel not only reflects what to display on View but also contain the logic of the View. So, That makes sense if some if-else
are put in the ViewModel
. But, If there is no logic then we can bind that ViewModle
directly.
Reducer
is needed to compute the state depend on 2 parameters (previous state and the results). You can use both or you can use one of them.
Looks like previous
Redux
sample but addViewModel
. So theView
is very clean. Try it in production. The nameEffect
is not cool instead ofEpic
.Store
overViewModel
, right?. How about scoping withStore
likeCheckoutScope
,FilterScope
?