Flarum (v1.8.19)
    Preparing search index...

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

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    alerts: AlertManagerState = ...

    An object that manages the state of active alerts.

    booted: boolean = false

    Whether or not the app has been booted.

    cache: Record<string, unknown> = {}

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

    current: PageState = ...

    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.

    deferredRequests: Map<
        string,
        {
            options: FlarumRequestOptions<any>;
            settlers: {
                reject: (error: unknown) => void;
                resolve: (value: any) => void;
            }[];
        },
    > = ...

    GET requests that failed because the browser was offline, keyed by method, URL and params. They are retried, and their original promises settled, once connectivity is restored. Identical requests (e.g. from a polling extension) share one entry and are retried only once.

    drawer: Drawer

    An object that manages the state of the navigation drawer.

    forum: Forum

    The forum model for this application.

    history: IHistory | null = null
    initializers: ItemList<(app: this) => void> = ...

    An ordered list of initializers to bootstrap the application.

    initialRoute: string
    modal: ModalManagerState = ...

    An object that manages modal state.

    networkErrorAlert: number | null = null

    The key for the Alert that was shown as a result of an AJAX request failing at the network level (status 0). Unlike other request error alerts, only one of these is shown at a time.

    offlineAlert: number | null = null

    The key for the Alert that is shown while the browser reports being offline.

    pane: any = null
    previous: PageState = ...

    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.

    refs: Record<string, string> = ...
    routes: Record<string, FlarumGenericRoute> = {}

    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.
    app.routes.discussion = { path: '/d/:id', component: DiscussionPage };
    
    session: Session

    The app's session.

    Stores info about the current user.

    store: Store = ...

    The app's data store.

    translator: Translator = ...

    The app's translator.

    Methods

    • Protected

      Used to modify the error message shown on the page to help troubleshooting. While not certain, a failing cross-origin request likely indicates a missing redirect to Flarum canonical URL. Because XHR errors do not expose CORS information, we can only compare the requested URL origin to the page origin.

      Parameters

      Returns boolean

    • Whether a failed request should be held back and retried once connectivity is restored, instead of being rejected.

      Only GET requests that failed at the network level while the browser reported being offline qualify: they are safe to repeat, and the online event provides a reliable signal to retry them.

      Parameters

      Returns boolean