Reputation: 953
What is the best approach for the Alloy controllers? What's the difference? data variable will never 'get out' of the controller:
var args = arguments[0] || {},
data = {};
data.title = args.name+', '+args.age;
console.log(data.title);
or
var data = {};
(function(args){
data.title = args.name+', '+args.age;
console.log(data.title);
}),arguments[0] || {});
Other thing, I'm using elements in my all controllers (buttons, forms, tables, etc..) actually, these elements are widgets, should they be simple controllers? there is any disadvantage of use widgets instead of a simple controller
Upvotes: 0
Views: 78
Reputation: 24815
Within a controller there is no need to use a self executing function, the only reason there possibly can be is personal preference.
Your second question about elements is also personal preference. But since Widgets require you to set up a widget.json
and include it in the config
it has slight overhead. Not in terms of performance. You could just as well use a regular controller. Again, question of preference.
However, I do usually have this rule for myself: Wigets are things you want to use in other apps / open source. Controllers are 1-app only.
Upvotes: 2