Sorting Numbers
Example
import bubleSort from "./algorithms/bublesort";
const numbers = [...Array(50000)].map(() =>
Math.floor(Math.random() * 1000000)
);
function App() {
const [sortWorker, { status: sortWorkerStatus, kill: killWorker }] = useWorker(bubleSort);
const onWorkerSortClick = () => {
sortWorker(numbers).then(result => {
console.log("Buble Sort useWorker()", result);
addToast("Finished: Sort using useWorker.", { appearance: "success" });
});
};
}
See Full code Github