Skip to content

Instantly share code, notes, and snippets.

@reed-lawrence
Created December 3, 2019 19:49
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/27aee82cd16b1a6dc8e1b04f774a4286 to your computer and use it in GitHub Desktop.
Save reed-lawrence/27aee82cd16b1a6dc8e1b04f774a4286 to your computer and use it in GitHub Desktop.
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