rxjs-in-action
rxjs-in-action copied to clipboard
Listing 4.7 code doesn't match associated marble diagram
https://github.com/RxJSInAction/rxjs-in-action/blob/master/examples/4/7/4_7.js
does not correspond to the marble diagram (p.99, Figure 4.8) of 4.3.1 Propagation. Due to the use of the of static operator there is only a single event containing an array of five elements - not five events as depicted in the marble diagram. For that the from static operator has to be used:
const showEmitted = x => console.log(`Emitted: ${x}`);
const showReceived = x => console.log(`Received: ${x}`);
Rx.Observable.from([1, 2, 3, 4, 5])
.do(showEmitted)
.delay(200)
.subscribe(showReceived);
// Output:
// Emitted: 1
// Emitted: 2
// Emitted: 3
// Emitted: 4
// Emitted: 5
// ... 200 milliseconds later...
// Received: 1
// Received: 2
// Received: 3
// Received: 4
// Received: 5
Yup. You're absolutely right. That should have been Observable.from(...). @paulpdaniels Let's add this to the errata page. Thanks @peerreynders for the catch!