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

Is it possible to render the loading page depending on the server's response speed? #730

Open
young-do opened this issue Aug 3, 2020 · 1 comment

Comments

@young-do
Copy link

young-do commented Aug 3, 2020

Hi @taion
I can't solve the above question and I'm trying to get your help.

When a loading page is set through a render function, the loading page is always shown regardless of the server's response speed.
However, if the response from the server is very fast, it is thought that rendering the loading page is an unnecessary act, and it is an unpleasant UX.

For example, if response from the server before 200ms after querying, show the next page without rendering the loading page, and if response passed 200ms, show the loading page.

@taion
Copy link
Contributor

taion commented Aug 3, 2020

It's possible in principle, but it's not really straightforward (and it shows the limitations of trying to do this without suspense/concurrent mode).

Are you using Found Relay here?

The rough approach here is that we'd want to modify the resolver such that, instead of immediately yielding the first set of pending elements, that we'd race against a timeout, and only yield them if the "final" elements don't show up in time.

In Found,

found/src/resolver.js

Lines 45 to 47 in dbd0177

yield pendingElements.every((element) => element !== undefined)
? pendingElements
: undefined;

In Found Relay, https://github.com/relay-tools/found-relay/blob/master/src/Resolver.js#L81-L83

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

No branches or pull requests

2 participants