Home>IT Tests>Questions>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]));
}
}
```
Question from the Introduction to RxJS test
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])); } } ```
Medium
How this way of doing is called?
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]));
}
}
Author: Amine BouchamStatus: PublishedQuestion passed 90 times
Edit
0
Community EvaluationsNo one has reviewed this question yet, be the first!