hypothesis / lms

LTI app for integrating with learning management systems
BSD 2-Clause "Simplified" License
45 stars 14 forks source link

Allow route modules to define what parts of the loader don't need to be awaited #6360

Closed acelaya closed 1 month ago

acelaya commented 1 month ago

This is a continuation of https://github.com/hypothesis/lms/pull/6342 and https://github.com/hypothesis/lms/pull/6357, which enhances the route loaders so that, instead of returning a promise, they return an object with this shape:

type LoaderResult = {
  awaitable: Promise<unknown>;
  rest: Record<string, Promise<unknown>;
}

This tells the component orchestrating route transitions that the awaitable promise needs to be settled before rendering the new route's component, but the rest can be passed verbatim, and let the component itself handle errors and loading state by wrapping them in useFetch.

acelaya commented 1 month ago

Closing for now, until we come back to this.