Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question on suspense #245

Open
windmaomao opened this issue May 12, 2021 · 2 comments
Open

question on suspense #245

windmaomao opened this issue May 12, 2021 · 2 comments
Labels
question Further information is requested

Comments

@windmaomao
Copy link

this is an awesome library.

and i just have a question, how does suspense fit into this picture ? I know React team might take it to very wild implementation. But IMHO, isn't hook going to at least help on this problem.

  const [data] = useResourceOrCache()

Of course, somehow createSuspense might have to be included in the parent, because this hook needs to communicate with the parent. Ok, we can have <Suspense ... />.

Then is this a bit similar to the design of Context, once the children resource is resolved, it'll notify the parent Suspense.

Now I wonder if i can just use a Context to simulate Suspense, for some reason i also wonder if suspense is a such bad idea. Because how do I know what to suspend for. Anyway.

@matthewp
Copy link
Owner

There's no concept of Suspense in Haunted. I think it's very unlikely we'll ever add it for similar reasons as to why Preact isn't doing so.

@matthewp matthewp added the question Further information is requested label Jun 16, 2021
@nlundquist
Copy link

I believe that Suspense functionality becoming stable in Preact 11 preactjs/preact#2915

@windmaomao I have used Contexts to implement Suspense-like behavior in a Haunted app before. The implementation could be generalized and improved though. Might be some inspiration:
https://github.com/nre-learning/antidote-web/blob/master/templates/labs/index.html
https://github.com/nre-learning/antidote-ui-components/blob/master/components/lab-context.js
https://github.com/nre-learning/antidote-ui-components/blob/master/components/lab-guide.js#L75-L116

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants