NavigationEventDispatcher


public final class NavigationEventDispatcher


Dispatcher that can be used to register NavigationEventCallback instances for handling the in-app callbacks via composition.

Summary

Public constructors

NavigationEventDispatcher(Function0<Unit> fallbackOnBackPressed)

Dispatcher that can be used to register NavigationEventCallback instances for handling the in-app callbacks via composition.

NavigationEventDispatcher(
    Function0<Unit> fallbackOnBackPressed,
    Function1<@NonNull BooleanUnit> onHasEnabledCallbacksChanged
)

Public methods

final void

Add a new NavigationEventCallback.

final void

Dispatch an NavigationEventCallback.onEventCancelled event with the given event to the proper callbacks

final void

Dispatch an NavigationEventCallback.onEventCompleted event with the given event to the proper callbacks

final void

Dispatch an NavigationEventCallback.onEventProgressed event with the given event to the proper callbacks

final void

Dispatch an NavigationEventCallback.onEventStarted event with the given event to the proper callbacks

final boolean

Returns true if there is at least one NavigationEventDispatcher.isEnabled callback registered with this dispatcher.

Public constructors

Added in 1.0.0-alpha01
public NavigationEventDispatcher(Function0<Unit> fallbackOnBackPressed)

Dispatcher that can be used to register NavigationEventCallback instances for handling the in-app callbacks via composition.

Added in 1.0.0-alpha01
public NavigationEventDispatcher(
    Function0<Unit> fallbackOnBackPressed,
    Function1<@NonNull BooleanUnit> onHasEnabledCallbacksChanged
)

Public methods

addCallback

@MainThread
public final void addCallback(
    @NonNull NavigationEventCallback callback,
    @NonNull NavigationEventPriority priority
)

Add a new NavigationEventCallback. Callbacks are invoked in the reverse order in which they are added, so this newly added NavigationEventCallback will be the first callback to be called.

To remove a callback, use NavigationEventCallback.remove.

The callbacks provided will be invoked on the main thread.

dispatchOnCancelled

Added in 1.0.0-alpha01
@MainThread
public final void dispatchOnCancelled()

Dispatch an NavigationEventCallback.onEventCancelled event with the given event to the proper callbacks

dispatchOnCompleted

Added in 1.0.0-alpha01
@MainThread
public final void dispatchOnCompleted()

Dispatch an NavigationEventCallback.onEventCompleted event with the given event to the proper callbacks

dispatchOnProgressed

Added in 1.0.0-alpha01
@MainThread
public final void dispatchOnProgressed(@NonNull NavigationEvent event)

Dispatch an NavigationEventCallback.onEventProgressed event with the given event to the proper callbacks

Parameters
@NonNull NavigationEvent event

NavigationEvent to dispatch to the callbacks.

dispatchOnStarted

Added in 1.0.0-alpha01
@MainThread
public final void dispatchOnStarted(@NonNull NavigationEvent event)

Dispatch an NavigationEventCallback.onEventStarted event with the given event to the proper callbacks

Parameters
@NonNull NavigationEvent event

NavigationEvent to dispatch to the callbacks.

hasEnabledCallbacks

Added in 1.0.0-alpha01
public final boolean hasEnabledCallbacks()

Returns true if there is at least one NavigationEventDispatcher.isEnabled callback registered with this dispatcher.

Returns
boolean

True if there is at least one enabled callback.