Skip to content

Instantly share code, notes, and snippets.

@vhqtvn

vhqtvn/vue-no-reactive.ts

Last active Aug 28, 2019
Embed
What would you like to do?
/* 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