Skip to content

Instantly share code, notes, and snippets.

@vhqtvn
Last active August 28, 2019 03:45
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 vhqtvn/e0e379b01ff9cd8f8266399e28d7bb68 to your computer and use it in GitHub Desktop.
Save vhqtvn/e0e379b01ff9cd8f8266399e28d7bb68 to your computer and use it in GitHub Desktop.
/* tslint:disable */
export function NoObserver<T>(target: T): T {
if (target === null || typeof target === 'undefined') {
return target;
}
(target as any)._isVue = true;
return target;
}
export function NoReactiveProp(): PropertyDecorator {
return (target: Object, propertyKey: string | symbol) => {
Object.defineProperty((target as any), propertyKey, {
get: function () {
return this[`__noreactive__${propertyKey.toString()}`];
},
set: function (val: any) {
this[`__noreactive__${propertyKey.toString()}`] = NoObserver(val);
},
});
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment