Open
Description
Main thread #36
Inline dependencies
currently the worker dependencies are urls that will be injected through importScripts
, since react-scripts still does not support web workers, we could allow to inject functions and objects into the worker
Before:
const [sortWorker, sortWorkerStatus, killWorker] = useWorker(sortDates, {
dependencies: [
"https://cdnjs.cloudflare.com/ajax/libs/date-fns/1.30.1/date_fns.js"
],
}
const res = await sortWorker(dates)
After
const utils = {
manipulate: { ....}
add: {...}
}
const sortDates = (date) => {
var foo = utils.manipulate(date)
return foo
}
const [sortWorker, sortWorkerStatus, killWorker] = useWorker(sortDates, {
remoteDependencies: [
"https://cdnjs.cloudflare.com/ajax/libs/date-fns/1.30.1/date_fns.js"
],
localDependencies: [{ utils: utils }]
}
const res = await sortWorker(dates)
Metadata
Metadata
Assignees
Labels
No labels