I have the following code:
class MyClass {
private readonly clientId$: ReplaySubject<string>;
public get clientId(): Observable<string> {
return this.clientId$;
}
constructor([... things]) {
this.clientId$ = new ReplaySubject<string>(1);
someObservable
.pipe(
map(arg => {
// business logic and what not...
}))
.subscribe(clientId => {
this.clientId$.next(clientId);
});
}
}
I want to be able to use myClassInstance.clientId.value(); e.g. like a behavior subject. In addition to new subscribers of clientId getting the old value since someObservable fires infrequently.
Any ideas? Thank you in advance!