Reference Source
import History from 'flarum/forum/utils/History'
public class | source

History

The History class keeps track and manages a stack of routes that the user has navigated to in their session.

An item can be pushed to the top of the stack using the push method. An item in the stack has a name and a URL. The name need not be unique; if it is the same as the item before it, that will be overwritten with the new URL. In this way, if a user visits a discussion, and then visits another discussion, popping the history stack will still take them back to the discussion list rather than the previous discussion.

Constructor Summary

Public Constructor
public

Member Summary

Protected Members
protected

The stack of routes that have been navigated to.

Method Summary

Public Methods
public

back(): *

Go back to the previous route in the history stack.

public

backUrl(): *

Get the URL of the previous page.

public

Check whether or not the history stack is able to be popped.

public

Get the item on the top of the stack.

public

Get the previous item on the stack.

public

home()

Go to the first route in the history stack.

public

push(name: String, title: String, url: String)

Push an item to the top of the stack.

Public Constructors

public constructor() source

Protected Members

protected stack: Array source

The stack of routes that have been navigated to.

Public Methods

public back(): * source

Go back to the previous route in the history stack.

Return:

*

public backUrl(): * source

Get the URL of the previous page.

Return:

*

public canGoBack(): Boolean source

Check whether or not the history stack is able to be popped.

Return:

Boolean

public getCurrent(): Object source

Get the item on the top of the stack.

Return:

Object

public getPrevious(): Object source

Get the previous item on the stack.

Return:

Object

public home() source

Go to the first route in the history stack.

public push(name: String, title: String, url: String) source

Push an item to the top of the stack.

Params:

NameTypeAttributeDescription
name String

The name of the route.

title String

The title of the route.

url String
  • optional

The URL of the route. The current URL will be used if not provided.