Last active
December 3, 2020 01:38
-
-
Save radames/94470693d7346142878920a32aa0e3e8 to your computer and use it in GitHub Desktop.
test-mutable-generator.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="animation"></div> | |
<div class="slider"></div> | |
<p> | |
Credit: | |
<a | |
href="https://observablehq.com/@observablehq/how-to-embed-a-notebook-in-a-react-app" | |
>🤔 How to: Embed a Notebook in a React App by Observable</a | |
> | |
</p> | |
<script type="module"> | |
import { | |
Runtime, | |
Inspector | |
} from "https://cdn.jsdelivr.net/npm/@observablehq/runtime@4/dist/runtime.js"; | |
import define from "https://api.observablehq.com/@observablehq/how-to-embed-a-notebook-in-a-react-app.js?v=3"; | |
new Runtime().module(define, name => { | |
if (name === "animation") return Inspector.into(".animation")(); | |
if (name === "slider") return Inspector.into(".slider")(); | |
if (name === "mutable speed") | |
return { | |
pending() {}, | |
fulfilled(value) { | |
console.log(value); | |
(async () => { | |
for await (let v of value.generator) { | |
console.log(v); | |
} | |
})(); | |
}, | |
rejected(error) { | |
console.log("err", error); | |
} | |
}; | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment