Medium flatMap example
const Rx = require('rxjs');
const long$ = Rx.Observable.interval(1000).take(4);
const short$ = Rx.Observable.interval(500).take(4);
long$
.flatMap(long => short$.map(short => console.log({ long, short })))
.subscribe();
/** Output
{ long: 0, short: 0 }
{ long: 0, short: 1 }
{ long: 1, short: 0 }
{ long: 0, short: 2 }
{ long: 1, short: 1 }
{ long: 0, short: 3 }
{ long: 2, short: 0 }
{ long: 1, short: 2 }
{ long: 2, short: 1 }
{ long: 1, short: 3 }
{ long: 3, short: 0 }
{ long: 2, short: 2 }
{ long: 3, short: 1 }
{ long: 2, short: 3 }
{ long: 3, short: 2 }
{ long: 3, short: 3 }
*/