intercept
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.
Guard chaining: intercept blocks may be nested to arbitrary depth. Guards run in declaration order — outermost first. Navigation proceeds only when every guard in the chain returns GuardResult.Allow. The first non-Allow result stops evaluation immediately; inner guards are never called.
Multiple intercept blocks at the same level are independent — each wrapped graph accumulates only the guards that apply to it.
Example — single guard:
rootGraph {
start(startScreen)
screens(startScreen, loginScreen)
intercept(
guard = { store ->
if (store.selectState<AuthState>().value.isLoggedIn) GuardResult.Allow
else GuardResult.RedirectTo(loginScreen)
}
) {
graph("workspace") {
start(workspaceHome)
screens(workspaceHome, profileScreen)
}
}
}Example — chained guards (startup check → auth check):
rootGraph {
start(startScreen)
screens(startScreen, loginScreen)
intercept(
guard = { store ->
if (store.selectState<AppState>().value.startupReady) GuardResult.Allow
else GuardResult.Reject
}
) {
intercept(
guard = { store ->
if (store.selectState<AuthState>().value.isLoggedIn) GuardResult.Allow
else GuardResult.RedirectTo(loginScreen)
}
) {
graph("workspace") {
start(workspaceHome)
screens(workspaceHome, profileScreen)
}
}
}
}Parameters
Guard evaluated before navigation; returns GuardResult decision
How long to wait before showing the global loading modal (default 200ms)
Builder block containing the graphs and screens to protect