How to use the react-hooks-worker.exposeWorker function in react-hooks-worker

To help you get started, we’ve selected a few react-hooks-worker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dai-shi / react-hooks-worker / examples / 05_generator / src / slow_fib.worker.js View on Github external
async function* fib(x) {
  let x1 = 0;
  let x2 = 1;
  let i = 0;
  while (i < x) {
    yield `(calculating...) ${x1}`;
    // eslint-disable-next-line no-await-in-loop
    await new Promise((r) => setTimeout(r, 100));
    [x1, x2] = [x2, x1 + x2];
    i += 1;
  }
  yield x1;
}

exposeWorker(fib);
github dai-shi / react-hooks-worker / examples / 01_minimal / src / slow_fib.worker.js View on Github external
import { exposeWorker } from 'react-hooks-worker';

const fib = (i) => (i <= 1 ? i : fib(i - 1) + fib(i - 2));

exposeWorker(fib);
github dai-shi / react-hooks-worker / examples / 03_comparison / src / slow_fib.worker.js View on Github external
import { exposeWorker } from 'react-hooks-worker';

const fib = (i) => (i <= 1 ? i : fib(i - 1) + fib(i - 2));

exposeWorker(fib);
github dai-shi / react-hooks-worker / examples / 02_typescript / src / slow_fib.worker.js View on Github external
import { exposeWorker } from 'react-hooks-worker';

const fib = (i) => (i <= 1 ? i : fib(i - 1) + fib(i - 2));

exposeWorker(fib);

react-hooks-worker

React custom hooks for web workers

MIT
Latest version published 2 years ago

Package Health Score

45 / 100
Full package analysis