InterceptDefinition

data class InterceptDefinition(val guard: NavigationGuard, val loadingThreshold: Duration = 200.milliseconds, outerGuards: List<Pair<NavigationGuard, Duration>> = emptyList())(source)

Defines an intercept guard that applies to all navigation into a group of graphs, including deep links.

When NavigationGraphBuilder.intercept blocks are nested, the guards are chained so that the outermost guard always runs 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.

The chain is accumulated during graph construction via prependOuter and stored in outerGuards (outermost first). At runtime NavigationLogic iterates outerGuards before evaluating guard (the innermost guard).

Example — three-level chain (startup → auth → premium):

intercept(guard = { store ->
if (store.selectState<AppState>().value.startupReady) GuardResult.Allow
else GuardResult.Reject
}) {
intercept(guard = { store ->
if (store.selectState<AuthState>().value.isAuthenticated) GuardResult.Allow
else GuardResult.RedirectTo(loginScreen)
}) {
intercept(guard = { store ->
if (store.selectState<AuthState>().value.hasPremium) GuardResult.Allow
else GuardResult.RedirectTo(upgradeScreen)
}) {
graph("premium") {
entry(premiumHome)
screens(premiumHome)
}
}
}
}

Created by the NavigationGraphBuilder.intercept DSL method.

Parameters

guard

The innermost guard evaluated last in the chain; returns a GuardResult decision

loadingThreshold

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

outerGuards

Outer guards accumulated during graph construction, evaluated outermost-first

See also

NavigationGraphBuilder.intercept

Constructors

Link copied to clipboard
constructor(guard: NavigationGuard, loadingThreshold: Duration = 200.milliseconds, outerGuards: List<Pair<NavigationGuard, Duration>> = emptyList())

Properties

Link copied to clipboard
Link copied to clipboard