@appscode/ui-builder
Version:
## Motivation
44 lines (40 loc) • 857 B
JavaScript
import { deepClone } from "fast-json-patch";
export default {
props: {
computedResponse: {
type: null,
default: "",
},
},
data() {
return {
updatePass: 0,
};
},
watch: {
computedResponse: {
immediate: true,
deep: true,
handler(n) {
if (
n !== null &&
n !== undefined &&
JSON.stringify(this.modelValue) !== JSON.stringify(n)
) {
// make object to array
if (typeof n === "object" && !Array.isArray(n)) {
this.modelValue = Object.keys(n).map((key) => {
return {
key,
value: deepClone(n[key]),
};
});
} else {
this.modelValue = deepClone(n);
}
this.updatePass += 1;
}
},
},
},
};