all repos — h3 @ 2e9de06504275c2d54a4bf969e76836bf4abb460

A tiny, extremely minimalist JavaScript microframework.

Clarified that setup and teardown methods are async.
h3rald h3rald@h3rald.com
Sat, 23 May 2020 23:04:28 +0200
commit

2e9de06504275c2d54a4bf969e76836bf4abb460

parent

e074e9497b1f3d33f8d292d9b17628f78ed9362c

2 files changed, 5 insertions(+), 3 deletions(-)

jump to
M docs/H3_DeveloperGuide.htmdocs/H3_DeveloperGuide.htm

@@ -7515,11 +7515,12 @@ <li>may have built-in local state, initialized during setup and (typically) destroyed during teardown.</li>

</ul> -<p>Route components are stll created using ordinary function returning a VNode, but you can optionally define a <strong>setup</strong> and a <strong>teardown</strong> method on them (Functions are Objects in JavaScript after all&hellip;) to be executed during the corresponding phase.</p> +<p>Route components are stll created using ordinary function returning a VNode, but you can optionally define a <strong>setup</strong> and a <strong>teardown</strong> async methods on them (Functions are Objects in JavaScript after all&hellip;) to be executed during the corresponding phase.</p> <p>Note that: * Both the <strong>setup</strong> method take an object as a parameter, representing the component state. Such object will be empty the first time the <strong>setup</strong> method is called for a given component, but it may contain properties not removed during teardowns. -* The <strong>teardown</strong> method can return an object, which will be retained as component state. If however nothing is returned, the component state is deleted.</p> +* The <strong>teardown</strong> method can return an object, which will be retained as component state. If however nothing is returned, the component state is deleted. +* Both methods can be asynchronous, in which case H3 will wait for their completion before proceeding.</p> <a name="How-everything-works..."></a> <h3>How everything works&hellip;<a href="#document-top" title="Go to top"></a></h3>
M docs/md/key-concepts.mddocs/md/key-concepts.md

@@ -85,11 +85,12 @@

* may have a dedicated *setup* (after the route component is added to the DOM) and *teardown* phase (after the route component is removed from the DOM and the new route component is loaded). * may have built-in local state, initialized during setup and (typically) destroyed during teardown. -Route components are stll created using ordinary function returning a VNode, but you can optionally define a **setup** and a **teardown** method on them (Functions are Objects in JavaScript after all...) to be executed during the corresponding phase. +Route components are stll created using ordinary function returning a VNode, but you can optionally define a **setup** and a **teardown** async methods on them (Functions are Objects in JavaScript after all...) to be executed during the corresponding phase. Note that: * Both the **setup** method take an object as a parameter, representing the component state. Such object will be empty the first time the **setup** method is called for a given component, but it may contain properties not removed during teardowns. * The **teardown** method can return an object, which will be retained as component state. If however nothing is returned, the component state is deleted. +* Both methods can be asynchronous, in which case H3 will wait for their completion before proceeding. ### How everything works...