in android/libraries/rib-router-navigator/src/main/kotlin/com/uber/rib/core/RouterNavigator.kt [75:247]
public fun popState()
/**
* Switch to a new state - this will switch out children if the state is not the current active
* state already.
*
* NOTE: This will retain the Riblet in memory (if [RouterNavigatorState.isCacheable] is TRUE)
* until it is popped or detached by a push with certain flags.
*
* @param newState to switch to.
* @param attachTransition method to attach child router.
* @param detachTransition method to clean up child router when removed.
* @param <R> router type to detach. </R>
*/
public fun <R : Router<*>> pushState(
newState: StateT,
attachTransition: AttachTransition<R, StateT>,
detachTransition: DetachTransition<R, StateT>?,
)
/**
* Switch to a new state - this will switch out children if the state is not the current active
* state already. The transition will be controlled by the [StackRouterNavigator.Flag] provided.
*
* NOTE: This will retain the Riblet in memory (if [RouterNavigatorState.isCacheable] is TRUE)
* until it is popped or detached by a push with certain flags.
*
* @param newState to switch to.
* @param attachTransition method to attach child router.
* @param detachTransition method to clean up child router when removed.
* @param <R> router type to detach. </R>
*/
public fun <R : Router<*>> pushState(
newState: StateT,
flag: Flag,
attachTransition: AttachTransition<R, StateT>,
detachTransition: DetachTransition<R, StateT>?,
)
/**
* Switch to a new state - this will switch out children if the state is not the current active
* state already.
*
* NOTE: This will retain the Riblet in memory (if [RouterNavigatorState.isCacheable] is TRUE)
* until it is popped. To push transient, riblets, use [RouterNavigator.pushTransientState]
*
* Deprecated: Use pushState(newState, attachTransition, detachTransition)
*
* @param newState to switch to.
* @param attachTransition method to attach child router.
* @param detachTransition method to clean up child router when removed.
* @param <R> router type to detach. </R>
*/
@Deprecated("")
public fun <R : Router<*>> pushRetainedState(
newState: StateT,
attachTransition: AttachTransition<R, StateT>,
detachTransition: DetachTransition<R, StateT>?,
)
/**
* Switch to a new state - this will switch out children if the state is not the current active
* state already.
*
* NOTE: This will retain the Riblet in memory (if [RouterNavigatorState.isCacheable] is TRUE)
* until it is popped. To push transient, riblets, use [RouterNavigator.pushTransientState]
*
* Deprecated: Use pushState(newState, attachTransition, null)
*
* @param newState to switch to.
* @param attachTransition method to attach child router.
* @param <R> [Router] type. </R>
*/
@Deprecated("")
public fun <R : Router<*>> pushRetainedState(
newState: StateT,
attachTransition: AttachTransition<R, StateT>,
)
/**
* Switch to a new transient state - this will switch out children if the state is not the current
* active state already.
*
* NOTE: Transient states do not live in the back navigation stack.
*
* Deprecated: Use pushState(newState, Flag.TRANSIENT, attachTransition, detachTransition)
*
* @param newState to switch to.
* @param attachTransition method to attach child router.
* @param detachTransition method to clean up child router when removed.
* @param <R> router type to detach. </R>
*/
@Deprecated("")
public fun <R : Router<*>> pushTransientState(
newState: StateT,
attachTransition: AttachTransition<R, StateT>,
detachTransition: DetachTransition<R, StateT>?,
)
/**
* Switch to a new transient state - this will switch out children if the state is not the current
* active state already.
*
* NOTE: Transient states do not live in the back navigation stack.
*
* Deprecated: Use pushState(newState, Flag.TRANSIENT, attachTransition, null)
*
* @param newState to switch to.
* @param attachTransition method to attach child router.
* @param <R> [Router] type. </R>
*/
@Deprecated("")
public fun <R : Router<*>> pushTransientState(
newState: StateT,
attachTransition: AttachTransition<R, StateT>,
)
/**
* Peek the top [Router] on the stack.
*
* @return the top [Router] on the stack.
*/
public fun peekRouter(): Router<*>?
/**
* Peek the top [StateT] on the stack.
*
* @return the top [StateT] on the stack.
*/
public fun peekState(): StateT?
/**
* Gets the size of the navigation stack.
*
* @return Size of the navigation stack.
*/
@IntRange(from = 0) public fun size(): Int
/**
* Must be called when host interactor is going to detach. This will pop the current active router
* and clear the entire stack.
*/
public fun hostWillDetach()
/**
* Allows consumers to write custom attachment logic when switching states.
*
* @param <StateT> state type. </StateT>
*/
public interface AttachTransition<RouterT : Router<*>, StateT : RouterNavigatorState> {
/**
* Constructs a new [RouterT] instance. This will only be called once.
*
* @return the newly attached child router.
*/
public fun buildRouter(): RouterT
/**
* Prepares the router for a state transition. [StackRouterNavigator] will handling attaching
* the router, but consumers of this should handle adding any views.
*
* @param router [RouterT] that is being attached.
* @param previousState state the navigator is transition from (if any).
* @param newState state the navigator is transitioning to.
*/
@UIEffect
public fun willAttachToHost(
router: RouterT,
previousState: StateT?,
newState: StateT,
isPush: Boolean,
)
}