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

How to cancel de previous execution? #118

Closed
LorhanSohaky opened this issue Mar 7, 2022 · 2 comments
Closed

How to cancel de previous execution? #118

LorhanSohaky opened this issue Mar 7, 2022 · 2 comments
Assignees
Labels
question Further information is requested
Milestone

Comments

@LorhanSohaky
Copy link

I'm trying to use fuzzy search in a worker, but I'm having the following error:

[useWorker] You can only run one instance of the worker at a time, if you want to run more than one in parallel, create another instance with the hook useWorker()

Code:

import debounce from 'lodash.debounce'
import { useWorker, WORKER_STATUS } from "@koale/useworker";

const fuseSearch = ({ list, query, limit, options }) => {
  // my fuse search
}

const MyComponent = () => {
  const [search, controller] = useWorker(fuseSearch)
  
  const handleInputChange = debounce(async value => {
    controller.kill()
    
    setLoading(true)
    try {
      const data = await search({ list: fundos, query: value, limit: 10, options })
      setLoading(false)
      setResultados(data)
    } catch (err) {
      if (err?.message) {
        setLoading(false)
        console.error(err)
      }
    }
  }, 300)
}
@LorhanSohaky LorhanSohaky added the question Further information is requested label Mar 7, 2022
@ashish-r
Copy link
Contributor

ashish-r commented May 21, 2022

There is an issue with the kill functionality of the library, I have created a fix for the same. Waiting for the maintainers to review and merge the same.
#122

@alewin alewin added this to the 4.1.0 milestone Oct 2, 2024
@alewin alewin moved this to Todo in useWorker TODOs Oct 2, 2024
@alewin
Copy link
Owner

alewin commented Oct 28, 2024

released [email protected] with the fixes ( #122 )

Apologies for the long wait, but due to personal and work-related reasons, I wasn’t able to maintain the library.
I’m well aware that forks and alternatives have emerged in the meantime, and I’m glad for it because the library was intentionally open-source with an MIT license to prevent issues like this.

Together with the new maintainer, @naorpeled, we are working to stabilize useWorker and add new features in the coming months. :)

@alewin alewin closed this as completed Oct 28, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in useWorker TODOs Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
Status: Done
Development

No branches or pull requests

4 participants