Untitled

mail@pastecode.io avatar
unknown
typescript
a year ago
606 B
7
Indexable
Never
import { Injectable } from '@angular/core';
import { ReplaySubject, Observable } from 'rxjs';
import { ExtendedUserInfo } from '../models/extended-user-info';

@Injectable()
export class UserInfoService {
    private subject: ReplaySubject<ExtendedUserInfo> = new ReplaySubject<ExtendedUserInfo>(1);

    public userInfo: Observable<ExtendedUserInfo> = this.subject.asObservable();

    public update(userInfo: ExtendedUserInfo): void {
        this.subject.next(userInfo);
    }

    public getUserInfo(): Observable<ExtendedUserInfo> {
        return this.subject.asObservable();
    }
}