Class History

    • Constructor Detail

      • History

        public History​(UI ui)
        Creates a history API endpoint for the given UI.
        Parameters:
        ui - the ui, not null
    • Method Detail

      • getUI

        public UI getUI()
        Gets the UI that this instance belongs to.
        Returns:
        the ui, not null
      • pushState

        public void pushState​(elemental.json.JsonValue state,
                              String location)
        Invokes history.pushState in the browser with the given parameters. This is a shorthand method for pushState(JsonValue, Location), creating Location from the string provided.
        Parameters:
        state - the JSON state to push to the history stack, or null to only change the location
        location - the new location to set in the browser, or null to only change the JSON state
      • pushState

        public void pushState​(elemental.json.JsonValue state,
                              Location location)
        Invokes history.pushState in the browser with the given parameters.
        Parameters:
        state - the JSON state to push to the history stack, or null to only change the location
        location - the new location to set in the browser, or null to only change the JSON state
      • replaceState

        public void replaceState​(elemental.json.JsonValue state,
                                 String location)
        Invokes history.replaceState in the browser with the given parameters. This is a shorthand method for replaceState(JsonValue, Location), creating Location from the string provided.
        Parameters:
        state - the JSON state to push to the history stack, or null to only change the location
        location - the new location to set in the browser, or null to only change the JSON state
      • replaceState

        public void replaceState​(elemental.json.JsonValue state,
                                 Location location)
        Invokes history.replaceState in the browser with the given parameters.
        Parameters:
        state - the JSON state to push to the history stack, or null to only change the location
        location - the new location to set in the browser, or null to only change the JSON state
      • setHistoryStateChangeHandler

        public void setHistoryStateChangeHandler​(History.HistoryStateChangeHandler historyStateChangeHandler)
        Sets a handler that will be notified when the history state has changed.

        History state changes are triggered when a popstate event is fired in the browser or when the user has navigated using a router link. There can only be one handler at a time.

        Parameters:
        historyStateChangeHandler - the handler to set, or null to remove the current handler
        See Also:
        History.HistoryStateChangeEvent
      • forward

        public void forward()
        Navigates forward. This has the same effect as if the user would press the forward button in the browser. This causes a History.HistoryStateChangeEvent to be fired asynchronously if the conditions described in the onpopstate documentation are met.
      • go

        public void go​(int steps)
        Navigates a number of steps forward or backward in the history. This has the same effect as if the user would press the forward button in the browser. This causes a History.HistoryStateChangeEvent to be fired asynchronously if the conditions described in the onpopstate documentation are met.
        Parameters:
        steps - the number of steps to navigate, positive numbers navigate forward, negative numbers backward. 0 causes the current page to be reloaded