#38 Pipe multiple actions

Emad Ibrahim
Jul 21, 2016 · 1 min read

Let’s say you have a button and you want it to perform multiple actions. Something like:

<button {{action 'do3Actions'}}>
let r1 = this.action1();
let r2 = this.action2(r1);
return this.action3(r2);

There’s a better way to do this:

<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

Originally published at Ember Daily Tips.

Emad Ibrahim

Written by

Husband, Father of Twins, Published Author, Entrepreneur, Passionate Technologist, Programmer and Productivity Nut. more at https://about.me/eibrahim