This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constructor(private state: AppStateService) { | |
this.state.onUserChanges.subscribe( | |
user => { console.log('New Email: ' + user.email); } | |
); | |
this.state.user = new User({ email: '[email protected]' }); | |
// console: New Email: [email protected]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface IAppStateService { | |
user: IUser; | |
onUserChanges: Subject<IUser>; | |
} | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class AppStateService implements IAppStateService { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface IAppStateService { | |
user: IUser; | |
onUserChanges: Subject<IUser>; | |
} | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class AppStateService implements IAppStateService { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Subject } from 'rxjs'; | |
export interface IUser { | |
username: string; | |
email: string; | |
} | |
export class User implements IUser { | |
private _email: string = ''; | |
private _username: string = ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { User, IUser } from '../classes/user' | |
import { Subject } from 'rxjs'; | |
export interface IGlobalComponentState { | |
user: IUser; | |
} | |
export class GlobalComponentState implements IGlobalComponentState { | |
private _user: User = new User(); | |
onUserChanges = new Subject<User>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface IUser { | |
username: string; | |
email: string; | |
} | |
export class User implements IUser { | |
email: string = ''; | |
username: string = ''; | |
constructor(init?: Partial<IUser>) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
Injectable, | |
Injector, | |
ComponentFactoryResolver, | |
EmbeddedViewRef, | |
ApplicationRef, | |
ComponentRef | |
} from '@angular/core'; | |
@Injectable() |