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

Visualize multiple observables at the same time #25

Open
slavafomin opened this issue Jan 23, 2020 · 1 comment
Open

Visualize multiple observables at the same time #25

slavafomin opened this issue Jan 23, 2020 · 1 comment

Comments

@slavafomin
Copy link

slavafomin commented Jan 23, 2020

Hello!

Thank you for this great tool, it's really amazing!

However, it would be nice if we could be able to visualize multiple observables on a single screen in parallel.

Having this example:

const { interval } = Rx;
const { map, take, filter } = RxOperators;

const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

const numbers$ = interval(500).pipe(
  take(10),
  map(index => numbers[index])
);

const oddNumbers$ = numbers$.pipe(filter(number => number % 2 === 1));
const evenNumbers$ = numbers$.pipe(filter(number => number % 2 === 0));

[numbers$, oddNumbers$, evenNumbers$];

We should be able to visualize all three observables. This would be great to see how different transformations work (like in marble diagrams).

@azhil
Copy link

azhil commented Mar 7, 2020

@slavafomin, hello. 🙂

I think it's still possible to do it. In your case the only thing you need is to trigger all three at the same time. You can use from operator for it. But it might not look the way you expect it to look, I guess, because you will still see the very first stream completion visualization.

I made a little change to your code here:

const { from, interval } = Rx;
const { map, take, filter } = RxOperators;

const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

const numbers$ = interval(500).pipe(
  take(10),
  map(index => numbers[index])
);

const oddNumbers$ = numbers$.pipe(filter(number => number % 2 === 1));
const evenNumbers$ = numbers$.pipe(filter(number => number % 2 === 0));

from([numbers$, oddNumbers$, evenNumbers$]);

Please note from operator.

And here is the link to see the change in action: https://rxviz.com/v/9J9PZQqO.

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