Arrow functions have one big advantage over standard anonymous function literals: They inherit this from the outer scope, allowing it to be used without having to assign it to another local variable or pass it as an argument or use .bind(this).
The xmpp code in cadence does this quite a lot when passing callbacks to Strophe.
The anonymous literals should be replaced with arrow literals, and if named functions are passed, they should be wrapped in arrow literals which call the old function to maintain its binding.
Arrow functions have one big advantage over standard anonymous function literals: They inherit
this
from the outer scope, allowing it to be used without having to assign it to another local variable or pass it as an argument or use.bind(this)
.The xmpp code in cadence does this quite a lot when passing callbacks to Strophe.
The anonymous literals should be replaced with arrow literals, and if named functions are passed, they should be wrapped in arrow literals which call the old function to maintain its binding.