External Scripts

Example


Edit white-glitter-icji4


const sortDates = dates => {
// eslint-disable-next-line no-undef
return dates.sort(dateFns.compareAsc);
};
const [sortWorker, { status: sortWorkerStatus, kill: killWorker }] = useWorker(sortDates, {
timeout: 5000,
remoteDependencies: [
"https://cdnjs.cloudflare.com/ajax/libs/date-fns/1.30.1/date_fns.js"
]
});
const onWorkerSortClick = () => {
sortWorker(dates).then(result => {
console.log("Buble Sort useWorker()", result);
addToast("Finished: Sort using useWorker.", { appearance: "success" });
});
};

See Full code Github