Reference Source
import Application from 'flarum/common/Application'
public class | source

Application

The App class provides a container for an application, as well as various utilities for the rest of the app to use.

Member Summary

Public Members
public

An object that manages the state of active alerts.

public

Whether or not the app has been booted.

public

A local cache that can be used to store data at the application level, so that is persists between different routes.

public

The page the app is currently on.

public

data: *

public

drawer: *

public

The forum model for this application.

public
public

An ordered list of initializers to bootstrap the application.

public

modal: *

public

The page the app was on before the current page.

public

A map of routes, keyed by a unique route name.

public

The app's session.

public

The app's data store.

public

title: *

public
public

The app's translator.

Private Members
private

The key for an Alert that was shown as a result of an AJAX request error.

Method Summary

Public Methods
public

boot()

public

bootExtensions(extensions: *)

public

load(payload: *)

public

mount(basePath: string)

public

Get the API response document that has been preloaded into the application.

public

request(options: Object): Promise

Make an AJAX request, handling any low-level errors that may occur.

public

route(name: String, params: Object): String

Construct a URL to the route with the given name.

public

Determine the current screen mode, based on our media queries.

public

setTitle(title: String)

Set the <title> of the page.

public

setTitleCount(count: Integer)

Set a number to display in the <title> of the page.

public
Private Methods
private

showDebug(error: RequestError, formattedError: string[])

Public Members

public alerts: AlertManagerState source

An object that manages the state of active alerts.

public booted: Boolean source

Whether or not the app has been booted.

public cache: Object source

A local cache that can be used to store data at the application level, so that is persists between different routes.

public current: PageState source

The page the app is currently on.

This object holds information about the type of page we are currently visiting, and sometimes additional arbitrary page state that may be relevant to lower-level components.

public data: * source

public drawer: * source

public forum: Forum source

The forum model for this application.

public initialRoute: * source

public initializers: ItemList source

An ordered list of initializers to bootstrap the application.

public modal: * source

public previous: PageState source

The page the app was on before the current page.

Once the application navigates to another page, the object previously assigned to this.current will be moved to this.previous, while this.current is re-initialized.

public routes: Object source

A map of routes, keyed by a unique route name. Each route is an object containing the following properties:

  • path The path that the route is accessed at.
  • component The Mithril component to render when this route is active.

Example:

app.routes.discussion = {path: '/d/:id', component: DiscussionPage.component()};

public session: Session source

The app's session.

public store: Store source

The app's data store.

public title: * source

public titleCount: * source

public translator: Translator source

The app's translator.

Private Members

private requestErrorAlert: int source

The key for an Alert that was shown as a result of an AJAX request error. If present, it will be dismissed on the next successful request.

Public Methods

public boot() source

public bootExtensions(extensions: *) source

Params:

NameTypeAttributeDescription
extensions *

public load(payload: *) source

Params:

NameTypeAttributeDescription
payload *

public mount(basePath: string) source

Params:

NameTypeAttributeDescription
basePath string
  • optional
  • default:

public preloadedApiDocument(): Object | null source

Get the API response document that has been preloaded into the application.

Return:

Object | null

public request(options: Object): Promise source

Make an AJAX request, handling any low-level errors that may occur.

Params:

NameTypeAttributeDescription
options Object

Return:

Promise

See:

public route(name: String, params: Object): String source

Construct a URL to the route with the given name.

Params:

NameTypeAttributeDescription
name String
params Object

Return:

String

public screen(): String source

Determine the current screen mode, based on our media queries.

Return:

String

one of "phone", "tablet", "desktop" or "desktop-hd"

public setTitle(title: String) source

Set the <title> of the page.

Params:

NameTypeAttributeDescription
title String

public setTitleCount(count: Integer) source

Set a number to display in the <title> of the page.

Params:

NameTypeAttributeDescription
count Integer

public updateTitle() source

Private Methods

private showDebug(error: RequestError, formattedError: string[]) source

Params:

NameTypeAttributeDescription
error RequestError
formattedError string[]
  • optional