Return the dom and store as a js global so it doesn't get gc'd
This commit is contained in:
parent
b8c368aeb4
commit
b093d804c8
2 changed files with 4 additions and 4 deletions
2
scene.js
2
scene.js
|
@ -1,6 +1,6 @@
|
||||||
window.addEventListener("load", async () => {
|
window.addEventListener("load", async () => {
|
||||||
try {
|
try {
|
||||||
await Scheme.load_main("scene.wasm", {
|
hootDom = await Scheme.load_main("scene.wasm", {
|
||||||
user_imports: {
|
user_imports: {
|
||||||
document: {
|
document: {
|
||||||
getElementById(id) {
|
getElementById(id) {
|
||||||
|
|
|
@ -118,9 +118,7 @@
|
||||||
(button (@ (id "button")
|
(button (@ (id "button")
|
||||||
(type "button")
|
(type "button")
|
||||||
(click ,(lambda (e)
|
(click ,(lambda (e)
|
||||||
(! counter (1+ (! counter)))
|
(! counter (1+ (! counter))))))
|
||||||
;; Hacky hack to ensure root-ref isn't GC'd too early...
|
|
||||||
(display root-ref))))
|
|
||||||
"Counter: "
|
"Counter: "
|
||||||
,counter)
|
,counter)
|
||||||
(button (@ (click ,(lambda (e) (! counter 0))))
|
(button (@ (click ,(lambda (e) (! counter 0))))
|
||||||
|
@ -134,3 +132,5 @@
|
||||||
`(p "I want to see " ,(~ (- 20 (! counter))) " more")))))
|
`(p "I want to see " ,(~ (- 20 (! counter))) " more")))))
|
||||||
|
|
||||||
(append-child! (document-body) (element-ref-element root-ref))
|
(append-child! (document-body) (element-ref-element root-ref))
|
||||||
|
|
||||||
|
root-ref
|
||||||
|
|
Loading…
Reference in a new issue