Action on multiple views
See original GitHub issueIt is a suggestion/question to get feedback on idea of applying action onto multiple views instead of a single right now. Sometimes it is needed to disable/enable multiple views based on a property change (e.g. Observable<Boolean>). If we have 3-4 views to control it we would need to write setEnabled for each one, instead of listing what views to disable.
We could do something like this:
@SafeVarargs
public static Action1<? super Boolean> allOf(Action1<? super Boolean>... actions) {
return t -> {
for (Action1<? super Boolean> action : actions) {
action.call(t);
}
};
}
Then we have following:
// before
viewModel.isLoading.subscribe(isLoading -> {
email.setEnabled(!isLoading);
password.setEnabled(!isLoading);
});
// after
viewModel.isLoading.map(isLoading -> !isLoading).subscribe(allOf(RxView.enabled(email), RxView.enabled(password)));
Any thoughts/feedback?
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Asp.Net MVC can have one action method for multiple views?
No you cant have multiple views returned from single action. In case you want in that way then, you can do it like...
Read more >MVC Action Method - Multiple Views - Stack Overflow
Yes, completely possible. And, it can be multiple views, or even a FileResult or other result type.
Read more >Create a View in ASP.NET MVC - TutorialsTeacher
A controller can have one or more action methods, and each action method can return a different view. In short, a controller can...
Read more >MVC Action Method - Multiple Views - CodeProject
hi to all, i am having same view with two different names i.e ContactUs, Enquirenow. for ContactUs View having layout,other one is no....
Read more >Multiple Models in Single View in MVC - C# Corner
There are many ways to use multiple models with a single view. ... We can render some part of a view by calling...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ll be very resistant adding it to RxBinding since it seems more appropriate as a generic thing for combining any RxJava
Action
s bounded by the same type. The advantages there are that you can optimize implementations for low counts and avoid the loop in the implementation as well as the array allocation for making the varargs method call. It also would allow you to combine multiple actions from unrelated views into a single stream (like two enabled’s, a checked, and a selected, for example).I would encourage you (or someone) to pursue this as a standalone project whose sole goal was the combination of the various
Action1
interfaces into helpers likeAction1s.combine(a, b, c)
or something.Well they are similar, but @VladimirLichonos 's library handles more cases. Mostly multi-parameter generic support seems to be the primary difference.