Skip to content
This repository has been archived by the owner on Sep 30, 2022. It is now read-only.

Add an example with a web worker #7

Open
Fil opened this issue Sep 7, 2019 · 1 comment
Open

Add an example with a web worker #7

Fil opened this issue Sep 7, 2019 · 1 comment
Assignees

Comments

@Fil
Copy link
Collaborator

Fil commented Sep 7, 2019

  const importScript = u =>
    window.location.href.includes(".observableusercontent.com")
      ? `https://unpkg.com/${u}`
      : `${window.location.href.replace(/\/[^/]*$/, "")}/${u}.js`;

  const worker = createWorkerFrom(`
  // load external scripts
  importScripts("${importScript("d3@5")}");
  importScripts("${importScript("d3-delaunay@5")}");
  …

`)
@Fil Fil self-assigned this Sep 7, 2019
@Fil
Copy link
Collaborator Author

Fil commented Sep 12, 2019

Another solution is to load the raw code as text and inject it in the preamble:

fq = d3.text(await require.resolve("flatqueue"))
worker(func, args, fq)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant