sveltefire icon indicating copy to clipboard operation
sveltefire copied to clipboard

loading state for collection reference

Open anasmohammed361 opened this issue 1 year ago • 1 comments

When using Collection , We dont trigger the loading state , as the initial value in never undefined.

  • Added the initial value as undefined in collection store.

https://github.com/codediodeio/sveltefire/issues/96

https://github.com/codediodeio/sveltefire/issues/140

https://github.com/codediodeio/sveltefire/issues/142

anasmohammed361 avatar Dec 06 '23 04:12 anasmohammed361

@codediodeio I am having the same issue, why not make the count prop start at -1 or allow startWith={undefined} to pass on the undefined state. I have created this hack:

<Collection ref={'taskLists'} let:data={taskLists} startWith={[{ loading: true }]} let:count={taskListCount}>
  {#if taskLists[0]?.loading}
    <Loading />
  {:else}
    <showTasks tasks={taskLists} />
  {/if}
  // Useless
  <svelte:fragment slot="loading"></svelte:fragment>
</Collection>

eyeofastarte avatar May 17 '24 08:05 eyeofastarte