Closed clemblanco closed 6 years ago
I wasn't aware about that. I just found it "sexier" to look at. :)
So a simple and normal function foo() { return 'bar'; }
is actually more efficient?
How much more efficient?
Not a lot, but right after creating the UI element it'll do:
global ? $.addListener($.__views.__alloyId0, "click", global) : __defers["$.__views.__alloyId0!click!global"] = true;
And since global
is not hoisted it wil push to the __defers
array which will later be used for:
__defers["$.__views.__alloyId0!click!global"] && $.addListener($.__views.__alloyId0, "click", global);
So it uses some memory and does an additional check.
Fair enough. I'll change it back again then.
Not very relevant for this test/sample of course, just curious why you did it :)
Closing for inactivity
@Claymm thanks, may I ask why you used named function expression? Because of how Alloy compiles the controller this is less efficient (it'll test for the availability to bind the UI callbacks twice)