Guest User

Untitled

a guest
Dec 13th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. type Constructor<T = {}> = new (...args: any[]) => T;
  2. function Watch<TBase extends Constructor>(Base: TBase) {
  3. return class extends Base {
  4. change$: Subject<any>;
  5. constructor(...args: any[]) {
  6. super(...args);
  7. this.change$ = new Subject<this>();
  8. return new Proxy(this, {
  9. set: function(obj: any, prop:any , value:any) {
  10. obj[prop] = value;
  11. obj.change$.next({
  12. obj,
  13. prop,
  14. value
  15. });
  16. return true;
  17. }
  18. })
  19. }
  20. };
  21. }
Add Comment
Please, Sign In to add comment