Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type Constructor<T = {}> = new (...args: any[]) => T;
- function Watch<TBase extends Constructor>(Base: TBase) {
- return class extends Base {
- change$: Subject<any>;
- constructor(...args: any[]) {
- super(...args);
- this.change$ = new Subject<this>();
- return new Proxy(this, {
- set: function(obj: any, prop:any , value:any) {
- obj[prop] = value;
- obj.change$.next({
- obj,
- prop,
- value
- });
- return true;
- }
- })
- }
- };
- }
Add Comment
Please, Sign In to add comment