Created
December 3, 2019 19:49
-
-
Save reed-lawrence/27aee82cd16b1a6dc8e1b04f774a4286 to your computer and use it in GitHub Desktop.
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 = ''; | |
onChanges = new Subject<this>(); | |
get email() { | |
return this._email; | |
} | |
set email(val: string) { | |
this._email = val; | |
this.onChanges.next(this); | |
} | |
get username() { | |
return this._username; | |
} | |
set username(val: string) { | |
this._username = val; | |
this.onChanges.next(this); | |
} | |
constructor(init?: Partial<IUser>) { | |
if (init) { | |
if (init.email) { this.email = init.email; } | |
if (init.username) { this.username = init.username; } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment