intercept

fun intercept(guard: NavigationGuard, loadingThreshold: Duration = 200.milliseconds, block: NavigationGraphBuilder.() -> Unit)(source)

Define a protected region where all nested graphs and screens require an intercept guard.

The guard is evaluated before navigation is committed to any route inside this block. It returns a GuardResult that decides whether to allow, reject, or redirect navigation.

If guard evaluation exceeds loadingThreshold, the global loading modal configured via loadingModal() at the module level is shown as a RenderLayer.SYSTEM overlay.

Example:

rootGraph {
entry(startScreen)
screens(startScreen, loginScreen)
intercept(
guard = { store ->
if (store.selectState<AuthState>().value.isLoggedIn) GuardResult.Allow
else GuardResult.RedirectTo(loginScreen)
}
) {
graph("workspace") {
entry(workspaceHome)
screens(workspaceHome, inviteScreen)
}
}
}

Parameters

guard

Guard evaluated before navigation; returns GuardResult decision

loadingThreshold

How long to wait before showing the global loading modal (default 200ms)

block

Builder block containing the graphs and screens to intercept