Replies: 5 comments 6 replies
-
|
Beta Was this translation helpful? Give feedback.
-
I need to think more about it, but just one quick thought: isnt |
Beta Was this translation helpful? Give feedback.
-
This I was thinking, what if we make the throwing behavior explicit? function Comp(){
const [resource] = createResource<{id: string}>(() => ...)
return (
<Suspense>
{resource()?.id}
{use(resource).id}
</Suspense>
)
}
Plus
Con
|
Beta Was this translation helpful? Give feedback.
-
I really like the throwing async design. Doing away with type narrowing is a huge benefit, and throwing granularly along makes a lot of sense to me. |
Beta Was this translation helpful? Give feedback.
-
Thanks @lxsmnsyc for laying out this discussion. I agree that there are 3 approaches here but I think they are slightly different. The last approach (Result) I think is always viable regardless as long as people don't opt into the primitives. Like you don't need Similarly I think splitting the pure/tracking parts effects is pretty much a must have. We would be so much better even today if we did that. So I'm going to approach this assuming some other changes have happened. I think it changes perspective on things. My Pro/Cons are a bit different I suppose. 1. Specific Primitive Non-Throwing (An update on what we do today)Introduce A ton of the flaws of the current system are addressed while leaving things mostly the same. Pros
Cons
VariationThere is a sub option to have only lazy memos. If done we can avoid even having 2. Specific Primitive Blocking (As described in my article)Again introduce Pros
Cons
3. Screw this stuffNo async primitives or maybe offer one if we want to make it more convenient instead of doing it in userland. Pros
Cons
Anyway I think it isn't too hard to picture the 3rd option, have that always be an option regardless.. I need to prototype the second option more I think to actually make the case for it. It has the potential to do things we haven't seen before, and need to understand if the fear is unwarranted. The first option is also perfectly fine if updated to address its current challenges. |
Beta Was this translation helpful? Give feedback.
-
This thread is more on discussing the current design of
createResource
andSuspense
behavior and in light with the recent article @ryansolid made.Current design
Pros
Cons
pending === undefined
is flawed. We cannot rely on it for checking pending states, because there can be some intent where the user's implementation actually returnsundefined
for the fetcher.Show
just to make sure the the data is guaranteed to be there, which then kills the non-blocking aspect of things.React's design principle on
createResource
' dataAssume that the "throw promise" behavior is implemented in the resource callback.
Pros
Show
is also dropped as a dependency for most people.Cons
Result<T>
Instead of
data()
, we only havedata.value
anddata.status
Pros
Cons
Other thoughts
There might be other patterns, pros and cons that I have missed, feel free to comment.
Beta Was this translation helpful? Give feedback.
All reactions