1.2.11 • Published 1 year ago

rewrk v1.2.11

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Rewrk

Version Prerequisite License: MIT

Dead simple React web workers.

API

useWorker<T extends Record<string, unknown>>(dynamicImport: Promise<T>, options?: WorkerOptions): ProxiedWorkerMethods<T>

Creates a worker from a dynamic import and returns a proxy object that can be used to call the worker's exported functions.

Arguments

  • dynamicImport - A function that returns dynamic import of the worker module. The module must export at least one function. Non-function exports will be stripped away.
  • options? - Options to pass to the worker constructor. By default the type option is set to "module".

Returns

A proxy object that can be used to call the worker's exported functions. The proxy object will be available immidiately despite the dynamic import returning a Promise.

Usage

import { useWorker } from "rewrk";

const WorkerComponent = () => {
    const worker = useWorker(import("./worker"));

    return <button onClick={() => worker.doSomething()}>Do something</button>;
};

License

MIT © Juan de Urtubey

1.2.11

1 year ago

1.2.10

1 year ago

1.2.9

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.0

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.6

1 year ago