angular-styleguide
angular-styleguide copied to clipboard
Ambiguity on usage of named functions
In Y024 is stated that named functions should be used for callbacks.
However, in all the examples unnamed functions are passed when chaining promises. I must say using named functions in promise chaining make the control flow hard to follow from my experience.
Is Y024 only intended for defining Angular components? Because that's what the example shows.
I agree that calling it callbacks
is somewhat confusing.
Use named functions instead of passing an anonymous function in as a callback.
perhaps this line should instead be:
Use named functions instead of passing an anonymous function when registering something to a module.
:+1: agree or just like this?
Use named functions instead of passing an anonymous function in as a callback
.
but it is a callback
@remcohaszing Yes, named functions are recommended for most scenarios unless it is a 1 liner.
To me, whether or not its a callback (which implies async unless I'm confused) under the hood isn't really something angular users need to know.
Totally acceptable as is IMO however.
Named functions are easier to follow, if a name is chosen well. Because they then say what will be done. If you don't need to go deeper, you are not bothered with it, makes it way easier to go through a flow of code imho.
The suggestions above are good ... anyone for a PR?