Open amydevs opened 1 year ago
This is useful because maybe you want to have a component that still works on the server side rendering, so you need a default value. On top of that, you need to be able to emit SUSPENSE
on the observable so you can switch to loading fallback, or emit an error to trigger a error boundary when there's an error.
Basically it's a way of using an observable to reify the 4 states of an asynchronous operation state machine:
It seems that using a subject that comes out of createSignal
, and composing it with a promise and binding it back into a component would be a useful way of doing this.
Overview
I have a component that is using a returned hook from the
bind
function. Within the docs examples, they trigger a suspense component's fallback by starting with emitting the SUSPENSE symbol on the observable passed to thebind
function. However, this does not work when I've passed a default value tobind
.The intention is to have a component that can have initial stale data that is to be hydrated from an observable
Recreation
I've first declared a signal and an asynchronous function:
Here, I've followed the SUSPENSE page in the API docs in creating a hook, passing in an observable that should start with a value of suspense:
I've also tried this variation:
And just only emitting SUSPENSE:
No matter whatever I do, except for removing the default
null
argument tobind
, thefallback
("Loading...") is not shown whenSUSPENSE
is being emitted.