Class NavigateEvent


public class NavigateEvent extends PrincipesEvent<NavigateEvent.NavigationPayload>
Represents a navigation event used for managing route transitions within an application. It encapsulates a payload describing the type of navigation action, the target route, and any additional parameters required for the navigation.

This class allows the creation of events to either push a new route, replace the current route, or navigate back (pop).

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    Represents the payload for a navigation event, providing details about the navigation action, target route, and optional parameters for the navigation.
    static enum 
    Defines the types of navigation actions available within the application.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a NavigateEvent with the specified navigation payload.
  • Method Summary

    Modifier and Type
    Method
    Description
    pop()
    Creates a navigation event for navigating back by removing the last route from the navigation stack.
    pop(String route)
    Creates a navigation event for navigating back to the specified route by removing the route from the navigation stack.
    push(String route)
    Creates a navigation event for navigating to the specified route by adding it to the navigation stack.
    replace(String route)
    Creates a navigation event to replace the current route with the specified route.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • NavigateEvent

      public NavigateEvent(NavigateEvent.NavigationPayload payload)
      Constructs a NavigateEvent with the specified navigation payload. The payload contains details about the navigation type, target route, and optional parameters for the navigation operation.
      Parameters:
      payload - the NavigateEvent.NavigationPayload containing information about the navigation action, including the route, action type (e.g., PUSH, REPLACE, POP), and any additional contextual parameters.
  • Method Details

    • push

      public static NavigateEvent push(String route)
      Creates a navigation event for navigating to the specified route by adding it to the navigation stack.
      Parameters:
      route - the target path or identifier of the route to be navigated to
      Returns:
      a NavigateEvent representing a PUSH navigation event with the specified route
    • replace

      public static NavigateEvent replace(String route)
      Creates a navigation event to replace the current route with the specified route. This operation replaces the top of the navigation stack without adding a new entry.
      Parameters:
      route - the target path or identifier of the route to navigate to
      Returns:
      a NavigateEvent representing a REPLACE event with the specified route
    • pop

      public static NavigateEvent pop()
      Creates a navigation event for navigating back by removing the last route from the navigation stack.
      Returns:
      a NavigateEvent representing a POP navigation event.
    • pop

      public static NavigateEvent pop(String route)
      Creates a navigation event for navigating back to the specified route by removing the route from the navigation stack.
      Parameters:
      route - the target path or identifier of the route to navigate back to
      Returns:
      a NavigateEvent representing a POP navigation event with the specified route