Reference Source
import Application from 'flarum/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

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

data: *

public

drawer: *

public

The forum model for this application.

public

An ordered list of initializers to bootstrap the application.

public

modal: *

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

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

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

Public Members

public alerts: * source

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 data: * source

public drawer: * source

public forum: Forum source

The forum model for this application.

public initializers: ItemList source

An ordered list of initializers to bootstrap the application.

public modal: * source

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 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

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 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