[Vuejs]-How can I use handler _.throttle function within watch function in Vue 3 Composition API?

0👍

As the solution was not shared, here is a working example.

import { watch } from "vue";
import { Inertia } from "@inertiajs/inertia";
import pickBy from "lodash/pickBy";
import throttle from "lodash/throttle";

Watch

watch(
  () => filters,
  throttle(() => {
    Inertia.get(route("users.index"), pickBy(filters), {
      preserveState: true,
    });
  }, 300),
  { deep: true }
);

Leave a comment