Reference Source
import App from 'flarum/App.js'
public class | source

App

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

Constructor Summary

Public Constructor
public

Member Summary

Public Members
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 forum model for this application.

public

An ordered list of initializers to bootstrap the application.

public

An object containing data to preload into the application.

public

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

public

The app's session.

public

The app's data store.

public
public
public

The app's translator.

Private Members
private

An Alert that was shown as a result of an AJAX request error.

Method Summary

Public Methods
public

boot()

Boot the application by running all of the registered initializers.

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

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

Public Constructors

public constructor() source

Public Members

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 forum: Forum source

The forum model for this application.

public initializers: ItemList source

An ordered list of initializers to bootstrap the application.

public preload: Object source

An object containing data to preload into the application.

Properties:

NameTypeAttributeDescription
preload.data Object

An array of resource objects to preload into the data store.

preload.document Object

An API response document to be used by the route that is first activated.

preload.session Object

A response from the /api/token endpoint containing the session's authentication token and user ID.

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: string source

public titleCount: number source

public translator: Translator source

The app's translator.

Private Members

private requestError: null | Alert source

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

Boot the application by running all of the registered initializers.

public preloadedDocument(): 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 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) source

Params:

NameTypeAttributeDescription
error RequestError