Skip to content

Deprecation: async‐fragment

Taylor Hunt edited this page Aug 2, 2019 · 3 revisions

The <async-fragment> tag and its friends are deprecated in favor of the <await> tag.

The effect of the new tags is the same as their deprecated equivalents.

Asynchronous data providers

<async-fragment data-provider=input.someData var="someVar" />

Instead, use the <@then> attribute tag with a parameter to rename the variable:

<await(input.someData)>
  <@then|someVar|></@then>
</await>

Asynchronous delivery of server-rendered templates

<async-fragments />

…becomes the client-reorder attribute on <await>:

<await client-reorder />

Placeholders

<async-fragment-placeholder>Loading…</async-fragment-placeholder>

…becomes the <@placeholder> attribute tag as a child of <await>:

<await>
  <@placeholder>Loading…</@placeholder>
</await>

Errors

<async-fragment-error>Request errored</async-fragment-error>

Promise rejections now display content with <@catch> attribute tags:

<await>
  <@catch>Request errored</@catch>
</await>

Timeouts

<async-fragment-timeout>Request timed out</async-fragment-timeout>

Timeout messages are now a special case of catching promise rejections, using <@catch> and a timeout attribute:

<await timeout=5000>
  <@catch|err|>
    <if(err.name === "TimeoutError")>Request timed out</if>
  </@catch>
</await>