title: How to handle dynamic array with svelte/store
body: <p>I would like to receive several data from different APIs and put it together in one big array. This array should be accessable for different components. The components should list the array, if all APIs are called and the data was collected.</p>
  <p>I adapted the code from <a href="https://svelte.dev/repl/9545e8959d63499b92a1073ae2fe1600?version=3.43.1" rel="nofollow noreferrer">REPL</a> and added a iteration, to call each API. The array will be filled, but the component is not showing the list. First, I thought its related to <a href="https://svelte.dev/tutorial/updating-arrays-and-objects" rel="nofollow noreferrer">reactivity / updating arrays</a>, but it also wont work.</p>
  <pre><code>import { writable } from 'svelte/store'
  export const API_LIST = [
      &quot;http://example1.com/api/&quot;,
      &quot;http://example2.com/api/&quot;
  ];
  
  export function readAll() {
      const { subscribe, update, set } = writable([])
      
      return {
          subscribe,
          init: async () =&gt; {
              let alldata = [];
              API_LIST.forEach(async function(apiurl) {
                  const res = await fetch(apiurl)
                  if (!res.ok) throw new Error('Bad response')
                  alldata.push( await res.json() );
                  alldata = alldata;
              });
              set(alldata);
              return alldata;
          }
      }
  }
  export const api_store = readAll()
  </code></pre>
  <p>My component:</p>
  <pre><code>&lt;script&gt;
      import { api_store } from 'reader.js';
  &lt;/script&gt;
  
  &lt;div&gt;
      {#await api_store.init()}
          &lt;p&gt;wait for reading...&lt;/p&gt;
      {:then}
          &lt;ul&gt;
          {#each $api_store as item}
              &lt;li&gt;
                  {item}
              &lt;/li&gt;
          {/each}
          &lt;/ul&gt;
      {:catch error}
          &lt;p&gt;Something went wrong: {error.message}&lt;/p&gt;
      {/await}
  &lt;/div&gt;
  </code></pre>
  <p>After all APIs are called and the array is build up, the &quot;wait for reading&quot; disappears, but the list showed is empty. I can see the array content with {console.info($api_store)}, so the data is present. But why is it not showing up in my component list?</p>