aboutsummaryrefslogtreecommitdiff
path: root/src/zilch/component.template.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/zilch/component.template.js')
-rw-r--r--src/zilch/component.template.js18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/zilch/component.template.js b/src/zilch/component.template.js
index e8cb914..6addef2 100644
--- a/src/zilch/component.template.js
+++ b/src/zilch/component.template.js
@@ -8,14 +8,12 @@ customElements.define("{s}-{s}", class extends HTMLElement {{
this[ZsPtr] = null;
}}
connectedCallback() {{
- wasm_ready.then(() => {{
- const id = ObjectStore.generateFreeId();
- ObjectStore.registerObject(id, this);
- this[ZsPtr] = wasm.exports['export::{s}::init'](id);
- }});
+ if (this[ZsPtr] === null) {{
+ wasm_ready.then(() => {{
+ const id = ObjectStore.generateFreeId();
+ ObjectStore.registerObject(id, this);
+ this[ZsPtr] = wasm.exports['export::{s}::init'](id, this[ZsPtr]);
+ }});
+ }}
}}
- disconnectedCallback() {{
- wasm.exports['export::{s}::deinit'](this[ZsId]);
- ObjectStore.free(this);
- }}
-}})
+}});