Skip to content

await once #955

Open
Open
@Rich-Harris

Description

@Rich-Harris

Follow-up to #952 / #654 (comment). It would modify the behaviour of await blocks such that you'd only see the 'pending' state once — thereafter, whenever a new promise value was set, the old one would be preserved until the promise resolved. An additional argument would be passed to the then block, allowing the UI to indicate that the currently displayed data was out of date:

<!-- autocomplete suggestion list — we don't want to blow away
     the previous set of suggestions while we're waiting for
     the server to send us some new ones -->
{{#await once suggestions}}
  <span>loading...</span>
{{then value, pending}}
  <datalist id='suggestions' style='opacity: {{pending ? 0.5 : 1}}'>
    {{#each value as suggestion}}
      <option>{{suggestion}}</option>
    {{/each}}
  </datalist>

  {{#if pending}}
    <span>updating...</span>
  {{/if}}
{{catch err}}
  <span class='error'>could not get suggestions!</span>
{{/await}}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions