R
R
Rooly2022-01-07 17:24:57
Vue.js
Rooly, 2022-01-07 17:24:57

Why debouncedWatch in the example?

Hello. I support the core of the project, I have already gone through a lot of shit (in my personal opinion, maybe I'm doing shit), but this completely led me to a dead end. Who used vueuse, explain to me, maybe a fool who has already read all of Google. not understanding what is happening here?

In general terms: The code is working with chips from vuetify.

debouncedWatch([() => props.filters, () => state.chips], () => {
      selectedFilters.value = reduce(
        props.filters,
        (result, value, key) => {
          if (value && state.chips[key]) result.push(key);
          return result;
        },
        [],
      );
    });


_.debounce is usually used in lodash when a delay is needed. There is no delay here.
Also here is an array of two, as it were, a function expression , which is also very incomprehensible to me.
I ask you to somehow chew, I really don’t have the strength

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2022-01-07
@ZetIndex_Ram

Also here is an array of two like a function expression

This allows you to react to changes in two props and not just in one
. As far as I understand, this debouncedWatchone can be replaced in your case with a regular one watch.
debouncedWatch should take debounced parameters as the second argument. You don't have that. And judging by the sources , the default delay value = 0

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question