Svelte: Modify Await Reference?

Viewed 129

Say I have:

{#await showMinePromise}
    <p>...Loading</p>
{:then entries}    
    // do stuff    
{/await}

Is there a way to update the entries variable to add in items (as when the user adds something, etc)? By that I mean manually insert an item into the array external to the await -- no call to update the promise.

1 Answers

You can do that :

<script>

  let fetchSomething = ... // some Promise
  let datas;

  fetchSomething.then(r => datas = r);
</script>

{#await fetchSomething}
  <p>Loading</p>
{:then}
  // use datas. it's updatable
{/await}

Related