SolidJSS
SolidJSโ€ข3y agoโ€ข
6 replies
kixelated

Resource from async generator?

Hey everyone, brand new to SolidJS.

I'm working with a library that uses an async generator to return the current state, and then await for any updates (or errors). This is close enough to a resource that I figured it would make sense to wrap the generator.

const gen = props.player.broadcasts()
const [broadcasts, { refetch }] = createResource(async () => {
    const next = await gen.next()
    if (next.done) {
        throw "unexpected end"
    }
    return next.value
})

// infinite refresh
createEffect(() => {
    broadcasts()
    refetch()
})


The problem is that the value doesn't seem to be reactive after a refetch. I can log that the value being returned on the refetch (next.value) is correct, but it doesn't trigger rendering or the effect to fire again.
Was this page helpful?