qwik icon indicating copy to clipboard operation
qwik copied to clipboard

[✨]Loading option for slow network in loader$

Open gabriiels opened this issue 2 years ago • 3 comments

Is your feature request related to a problem?

Being able to have the loading option when a loader$ is consumed, in the event that the response is not immediate

Describe the solution you'd like

/** Resulting data from an [operation]{@link Operation}. */
export interface OperationResult<Data = any, Variables extends AnyVariables = AnyVariables> {
    /** The [operation]{@link Operation} which has been executed. */
    operation: Operation<Data, Variables>;
    /** The data returned from the Graphql server. */
    data?: Data;
    /** Any errors resulting from the operation. */
    error?: CombinedError;
    /** Optional extensions return by the Graphql server. */
    extensions?: Record<string, any>;
    /** Optional stale flag added by exchanges that return stale results. */
    stale?: boolean;
    /** Optional hasNext flag indicating deferred/streamed results are following. */
    hasNext?: boolean;
   
    /* OptionaL loading flag indicating whether the operation is still in flight. */
    loading?: boolean;
}

Describe alternatives you've considered

This is what you can wear today. But it is not very flexible


<Resource
  value={weatherResource}
  onPending={() => <div>Loading...</div>}
  onRejected={() => <div>Failed to load weather</div>}
  onResolved={(weather) => {
    return <div>Temperature: {weather.temp}</div>;
  }}
/>

Additional context

No response

gabriiels avatar Feb 27 '23 03:02 gabriiels

Out of order rendering is not supported yet. but it's in the todo list

manucorporat avatar Feb 27 '23 09:02 manucorporat

@manucorporat would it be possible to have a routeLoader$ that only loads in the browser, not on the server? It is possible to use a useResource or a server$ function, however, these don't get prefetched on link hovers or refetched when an action$ is submitted.

This would be to support long running queries. I realise now this thread was actually for slow networks, sorry!

DustinJSilk avatar Apr 18 '23 22:04 DustinJSilk

@DustinJSilk But also for large queries it is the same case. Because if a slow network is coupled with a large query

gabriiels avatar Apr 18 '23 22:04 gabriiels

Out of order rendering will be in v2

PatrickJS avatar May 06 '24 16:05 PatrickJS