Skip to Content
JavaScript: Functional Programming for JavaScript Developers
book

JavaScript: Functional Programming for JavaScript Developers

by Ved Antani, Simon Timms, Dan Mantyla
August 2016
Intermediate to advanced
635 pages
14h 5m
English
Packt Publishing
Content preview from JavaScript: Functional Programming for JavaScript Developers

Merging streams

We've already seen the zip function that merges events one-to-one to create a new stream but there are numerous other ways of combining streams. A very simple example might be a page which has several code paths which all want to perform a similar action. Perhaps we have several actions all of which result in a status message being updated:

var button1 = document.getElementById("button1"); var button2 = document.getElementById("button2"); var button3 = document.getElementById("button3"); var button1Stream = Rx.Observable.fromEvent(button1, 'click'); var button2Stream = Rx.Observable.fromEvent(button2, 'click'); var button3Stream = Rx.Observable.fromEvent(button3, 'click'); var messageStream = Rx.Observable.merge(button1Stream, button2Stream, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering JavaScript Functional Programming

Mastering JavaScript Functional Programming

Federico Kereki

Publisher Resources

ISBN: 9781787124660