Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listing 4.7 code doesn't match associated marble diagram #17

Open
peerreynders opened this issue Mar 23, 2018 · 1 comment
Open

Listing 4.7 code doesn't match associated marble diagram #17

peerreynders opened this issue Mar 23, 2018 · 1 comment

Comments

@peerreynders
Copy link

peerreynders commented Mar 23, 2018

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
@luijar
Copy link
Collaborator

luijar commented Mar 25, 2018

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants