Easy
What is the difference between a Cold Observable and a Hot Observable?
Author: Amine BouchamStatus: PublishedQuestion passed 86 times
Edit
0
Community EvaluationsNo one has reviewed this question yet, be the first!
Similar QuestionsMore questions about RxJS
0
Why use name variables with **$** at the end in RxJS?0
Transform a dom event into an Observable0
What programming paradigm does RxJS bring?0
Which of these frameworks uses RxJS natively?0
How is this way of doing called?
```ts
interface UserData {
[key: string]: any;
}
class UserDataService {
private userData: BehaviorSubject<UserData> = new BehaviorSubject({});
private userData$: Observable<UserData> = this.userData.asObservable();
public setUserData(userData: UserData) {
this.userData.next(userData);
}
public getUserData(): Observable<UserData> {
return this.userData$;
}
public getUserDataByKey(key: string) {
return this.userData$.pipe(map((userData) => userData[key]));
}
}
```