DEV Community

Rxjs , Observeable

AbdulHadiBhagat on December 05, 2019

why is it that i can subscribe an observable more than one on same component when i can use it from only one subscriber

Collapse
 
leobm profile image
Felix Wittmann

?? please, show me your code. You can have multiple subscriptions to one observable.

import { from } from 'rxjs';


const example$ = from([1,2,3]);


const subscribe1 = example$.subscribe(val => console.log('First Subscriber:', val));
const subscribe2 = example$.subscribe(val => console.log('Second Subscriber:', val));

/*
Result:
First Subscriber: 1
First Subscriber:2
First Subscriber:3
Second Subscriber:1
Second Subscriber:2
Second Subscriber:3
*/
Collapse
 
nombrekeff profile image
Keff

More info would be great to be able to help out :)

Show me what you've got...
...
Show me what you've got...