Let’s say you have a button and you want it to perform multiple actions. Something like:
1 2 3 4 5 6 |
<button {{action 'do3Actions'}}> do3Actions(){ let r1 = this.action1(); let r2 = this.action2(r1); return this.action3(r2); } |
There’s a better way to do this:
1 |
<button {{action (pipe action1 action2 action3}}> |
NOTE: You will have to move your action1, 2 and 3 methods into the actions hash.
You can do that with the pipe helper in DockYard’s addon ember-composable-helpers.
PS: Thank you @dockyard for https://github.com/DockYard/ember-composable-helpers#pipe
Also published on Medium.