Oct 12, 2022
0
Level 15
computed factory - Dynamically generate computed properties
Any suggestion how to create/improve a computed factory function used to dynamically create computed getters and setter ?
I have a solutions witch is not perfect need to pass the emit to make it work.
export default function computedFactory(field, value, emit) {
return {
get() {
return value;
},
set(newValue: string) {
emit(`update:${field}`, newValue);
},
};
}
Please or to participate in this conversation.