sveltefire icon indicating copy to clipboard operation
sveltefire copied to clipboard

collectionStore seems to not be listening to real-time updates

Open masonstevens95 opened this issue 2 years ago • 1 comments

I have a collectionStore referenced in firebase.ts:

image

it is referenced in another file

image

In this file, I have tried several methods to make the UI re-render when something changes in firebase.

here is a function where it is being used:

image

where it is called:

image

the filtered data is passed as props

image

when I add a new document to the backend, no re-render appears to happen. any console.log statement that I would expect to fire does not.

masonstevens95 avatar Aug 14 '23 19:08 masonstevens95

Hi @masonstevens95, please correct me if I'm wrong but it seems like you are trying to derive a variable from your store right? If so, then you should use a svelte derived store for your plantsByForestLayer.

const plantsByForestLayer = derived(
        plantsByUUID,
        ($doc) => $doc.map(/* your code here */)
);

That way, you will be able to use plantsByForestLayer as a reactive variable in your template.

JeremyVoisin avatar Aug 22 '23 20:08 JeremyVoisin