Skip to content

Commit

Permalink
feat: update workaround checking params value
Browse files Browse the repository at this point in the history
  • Loading branch information
annacv committed Oct 2, 2024
1 parent d60636a commit 1c8e58a
Showing 1 changed file with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,16 @@
},
setup(props) {
const snippetConfig = inject('snippetConfig') as SnippetConfig;
const extraParams = ref<Record<string, unknown>>({});
const initialExtraParams = ref<Record<string, unknown>>({});
const extraParams = ref<Record<string, any>>({});
watch(
[() => snippetConfig, () => props.values],
() => {
const newExtraParams: Record<string, unknown> = {};
forEach({ ...props.values, ...snippetConfig }, (name, value) => {
if (!props.excludedExtraParams.includes(name)) {
newExtraParams[name] = value;
if (!props.excludedExtraParams.includes(name) && extraParams.value[name] !== value) {
extraParams.value = { ...extraParams.value, [name]: value };
}
});
// Check if extraParams are really changing to avoid event emission if they don't
if (JSON.stringify(newExtraParams) !== JSON.stringify(initialExtraParams.value)) {
extraParams.value = newExtraParams;
initialExtraParams.value = newExtraParams;
}
},
{
deep: true,
Expand Down

0 comments on commit 1c8e58a

Please sign in to comment.