preloadView function

Module @runic-artifex/views in @runic-artifex/views 0.23.0

function preloadView<TSource extends ViewConnector<ViewClient>>(source: TSource, options?: PreloadViewOptions): Promise<TSource>;

Connects a connector ahead of the component that shows it, such as in a router's load function, and keeps the client for keepAlive milliseconds: the first useView / injectView that follows the connector takes it over with its state, so the component renders the View at once instead of "Connecting…". Resolves with source, the value to hand to the component, once the client connected; rejects with the connection's failure, so the router shows its error page. A client that no binding takes over is released after keepAlive.

// SvelteKit, src/routes/editor/+page.ts
export const ssr = false;
export const load = async () => ({ editor: await preloadView({ connect: connectEditor }) });