⚛️ useWorker() - A React Hook for Blocking-Free Background Tasks
removed local dependencies #98 feature solves: #104, #105
Fix https://github.com/alewin/useWorker/issues/63 Unhandled Rejection (ReferenceError): OffscreenCanvas is not defined
Thanks to @IljaDaderko @Pigotz @gonzachr @JonatanSalas @z4o4z for the contribution.
useWorker
unnecessary re-renderautoTerminate
option docs
Before
const [sortWorker, status, kill] = useWorker(sortDates);
After
const [sortWorker, { status, kill }] = useWorker(sortDates);
dependencies
changes to remoteDependencies
Before
const [sortWorker] = useWorker(sortDates, { dependencies: ["www.google.com/script.js"] );
After
const [sortWorker] = useWorker(sortDates, { remoteDependencies: ["www.google.com/script.js"] );
These changes allow the addition of new features ( Roadmap 3.0.0 )
workerController
as second parameter
Why on each call to the worker the dependencies are re-fetched? https://github.com/alewin/useWorker/issues/33
Before:
the reference to the function workerHook
changes each time the workerStatus
changes, furthermore, since "options" is not a primitive variable, it causes a rerender every time the component that integrated the hook was updated.
After:
the hook updates only when options
and worker function
changes