vue-facing-decorator
Version:
Vue typescript class and decorator based component.
20 lines • 828 B
JavaScript
import { computed } from 'vue';
import { obtainSlot, optionNullableMemberDecorator } from '../utils';
export const decorator = optionNullableMemberDecorator(function (proto, name, key) {
const slot = obtainSlot(proto);
const map = slot.obtainMap('provide');
map.set(name, typeof key === 'undefined' ? null : key);
});
export function build(cons, optionBuilder, vueInstance) {
var _a;
(_a = optionBuilder.provide) !== null && _a !== void 0 ? _a : (optionBuilder.provide = {});
const slot = obtainSlot(cons.prototype);
const names = slot.obtainMap('provide');
if (!names)
return null;
names.forEach((value, name) => {
const key = value === null ? name : value;
optionBuilder.provide[key] = computed(() => vueInstance[name]);
});
}
//# sourceMappingURL=provide.js.map