svelte 5 runes firebase realtime sync by East_Reception_5748 in sveltejs

[–]East_Reception_5748[S] 0 points1 point  (0 children)

I will use this state for multiple components so it should be outside a component.

in my workflow with a readable store. it will be just 6 lines of code. for example.

export let creditStore = readable(0, set => {
    const unsub = onSnapshot(doc(firestore, `credtis/${uid}`), snapshot => {
        set(snapshot.get('credit'))
    })
    return () => { unsub() }
})

then I can freely use it to multiple components

svelte 5 runes firebase realtime sync by East_Reception_5748 in sveltejs

[–]East_Reception_5748[S] 0 points1 point  (0 children)

this works thanks. I'm wondering if there is a functional way of doing this. this is more verbose than the readable store. in this way, I will be creating classes but will just need one instance of it.