DEV Community

AbdulHadiBhagat
AbdulHadiBhagat

Posted on

Rxjs , Observeable

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

Top comments (2)

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...