ui-router-server / ssr / settle
Function: settle()
function settle(
router,
path,
options?
): Promise<Transition>;Defined in: ssr.ts:162
Moves router to path and resolves once the transition the url starts has landed, resolves included, so a synchronous render reads the router after it.
It never starts the router, which happens once per router (start() on a UIRouterLit, urlService.listen() on a core router): it sets the url and syncs the router to it, whether or not the router is listening. A page loop calls it once per path on the same router. A redirectTo chain settles on its final state, and a path the router already stands on resolves with the transition that brought it there. A redirect that ends where the router already stands resolves with the redirected transition, which becomes the router's last landed one, unless it leaves the url in place (location: false).
A failed transition still reaches stateService.defaultErrorHandler, which logs it unless replaced.
Parameters
| Parameter | Type | Description |
|---|---|---|
router | UIRouter | the server router, its location installed with installServerLocation |
path | string | the url to settle on, relative to the mount, query included |
options? | SettleOptions | how long to wait, and how many url rewrites to follow |
Returns
Promise<Transition>
the transition that landed
Throws
an Error when no url rule matches path and the router declares no otherwise
Throws
an Error whose cause is the transition's Rejection when it fails, a failed resolve's error in that rejection's detail
Throws
an Error when nothing lands within `timeout`
Throws
an Error when url rules rewrite the url more than `maxRewrites` times
Example
import type { UIRouter } from '@uirouter/core';
import { installServerLocation } from 'ui-router-server/location';
import { settle } from 'ui-router-server/ssr';
declare const router: UIRouter;
declare const pages: Map<string, string>;
declare function render(router: UIRouter): string;
installServerLocation(router, { urlConfig: { strict: false } });
for (const path of ['/', '/sheet/7B']) {
await settle(router, path);
pages.set(path, render(router));
}