Skip to content

Instantly share code, notes, and snippets.

@reed-lawrence
Created December 6, 2019 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reed-lawrence/f57d3207e8395fd6dad5d09b13f74ced to your computer and use it in GitHub Desktop.
Save reed-lawrence/f57d3207e8395fd6dad5d09b13f74ced to your computer and use it in GitHub Desktop.
export interface IAppStateService {
user: IUser;
onUserChanges: Subject<IUser>;
}
@Injectable({
providedIn: 'root'
})
export class AppStateService implements IAppStateService {
constructor() { }
private _user: User = new User();
onUserChanges = new Subject<User>();
get user() {
return this._user;
}
set user(val: User) {
console.log('new user emitted');
this._user = val;
this.onUserChanges.next(this._user);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment