-
Notifications
You must be signed in to change notification settings - Fork 703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Controller.resolve versus IIFE #14
Comments
Just use one IIFE, then all functions are in the same scope. |
Indeed, that'd what you recommend in your README 😄 In fact I though about @johnpapa's styleguide where each file is wrapped with an IIFE. I was more confident about collisions in the case you use variables out of the (main) function scope: (function() {
var foo = 'bar';
function FooController() {
this.foo = foo;
}
angular
.module('app')
.controller('FooController', FooController);
})(); but finally I don't think this is a good practice (mostly for testing purpose) |
Each file for me is an overkill, there isn't really need to and it gets a bit repetitive unless automated. Variables would be part of presentational logic if anything, therefore quite unique - just like the CSS we write, none of it should conflict with other parts of the app :) If you've got 1000 JavaScript files, 999 extra function calls isn't necessary either! |
Agreed with @toddmotto - I don't believe in bloating code with safeguards that would be avoidable using overhead-free best practices. A good variable naming convention could accomplish the same, in my opinion. |
automation makes this easy to remove if you need to. and if this is the biggest problem your app has, then you are in great shape. :) If you run locally in non automated mode (which a lot of devs do) the IIFE's give you a a truer sense of the global isolation than if you just avoid them. I use a template/snippet, and there are no slowdowns. Again, this is not a big deal as long as you do protect yourself in some way |
Ok, interesting point of view. Indeed, it's not a big deal, and there is not a single way to manage scripts compilation. Thanks for your answers |
Hello,
I just wonder how you can use the
Controller.resolve
property when using IIFE (assuming the routing config and the controller are in separate files).Using tools like Browserify solves this problem, but when you simply concat all your script files I don't see a way to use a property of the controller while configuring the router.
Any recommandation?
The text was updated successfully, but these errors were encountered: