Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue3 upgrade: vue-debounce-decorator #13853

Closed
severinbeauvais opened this issue Oct 7, 2022 · 3 comments
Closed

Vue3 upgrade: vue-debounce-decorator #13853

severinbeauvais opened this issue Oct 7, 2022 · 3 comments
Labels
ENTITY Business Team

Comments

@severinbeauvais
Copy link
Collaborator

Investigate/identify:

  • whether we can use this library in Vue3
  • what is missing to be able to use it (or when it will be available)
  • alternate packages (or whether we can change our code as needed)
  • what if we stop using this package altogether?
@severinbeauvais severinbeauvais added the ENTITY Business Team label Oct 7, 2022
@lambert-alex
Copy link

lambert-alex commented Oct 7, 2022

Vue 3 implementation in search-ui

Screenshot 2022-10-07 151610.png

@severinbeauvais
Copy link
Collaborator Author

severinbeauvais commented Jul 11, 2023

I came across this in a shared component. vue-debounce-decorator no longer worked with Vue 2.7.

Old:

import { Debounce } from 'vue-debounce-decorator'

/**
   * Called when prop changes (ie, v-model is updated by parent).
   * This method is debounced to prevent excessive validation.
   */
@Watch('value')
@Debounce(300)
private onValueChanged (val: string): void {
  this.emitValid(val)
}

New:

import { debounce } from 'lodash'

/**
   * Called when prop changes (ie, v-model is updated by parent).
   * This method is debounced to prevent excessive validation.
   */
@Watch('value')
private onValueChanged (val) {
  this.onValueChangedDebounced(val)
}

private onValueChangedDebounced = debounce((val: string) => {
  this.emitValid(val)
}, 300)

Since we have a working solution, I'm closing this ticket.

@severinbeauvais
Copy link
Collaborator Author

See also https://vueuse.org/useDebounceFn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ENTITY Business Team
Projects
None yet
Development

No branches or pull requests

2 participants