Skip to content

Conversation

@keystroke
Copy link

When running in Deno, I need to execute notebooks like this:

window.setImmediate = func => setTimeout(func, 0);
const { Runtime } = await import(
  "https://cdn.jsdelivr.net/npm/@observablehq/runtime@4/dist/runtime.js"
);

This requires me to set a mock / pollyfill of the setImmediate function, and then use a dynamic import for the runtime module. setTimeout should serve the same purpose and work in a wider variety of environments.

@keystroke
Copy link
Author

I added this so I could run the notebooks in Deno

@keystroke keystroke changed the title use setTimeout instead of setImmediate for better compatibility use setTimeout instead of setImmediate (for better compatibility with Deno) May 6, 2022
@mbostock
Copy link
Member

mbostock commented May 9, 2022

I’d prefer to use setImmediate if available, but if neither requestAnimationFrame nor setImmediate are available, we can fallback again to setTimeout.

@mbostock
Copy link
Member

mbostock commented May 9, 2022

Fixed in c439e62. Thanks for the suggestion.

@mbostock mbostock closed this May 9, 2022
@keystroke
Copy link
Author

@mbostock Thanks for the quick reply and addition! I am using this with a Netlify edge service I built (https://obs.run) to provide auto-generated wrapper scripts for executing ObservableHQ notebooks in Deno: https://observablehq.com/@keystroke/obs-run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants