UNPKG

simpa

Version:

Lightweight library for prototyping Single Page Applications.

60 lines (59 loc) 2.2 kB
import { View } from './view'; import { Component } from './component'; /** * Base class for Single Page Application. */ export declare class Application extends Component { /** Key name of the entry in sessionStorage where the reloading flag is stored. */ private readonly _reloadKey; /** HTML element that is a container for the whole application. */ private readonly _appContainer; /** Collection of all views defined in application. */ private readonly _views; /** * Creates a new application's object. * * @param build Application's buildNumber number. * @param appContainerId Identifier of the HTML element that serves as a container for the whole application. * @param className Class name for the application element. */ constructor(appContainerId: string, className: string); /** * Returns the HTML element that serves as a container for the whole application. * * @return Application's HTML element being a container for the whole application. */ get appContainer(): HTMLElement; /** * Returns a collection of all views defined for the application. * * @return Collection of views. */ get views(): View[]; doCreate(): void; doCreateViews(): void; doBuild(): void; doBuildViews(): void; doInit(): void; doInitViews(): void; addView(view: View): void; hideViews(): void; /** * Starts the application. */ start(): void; /** * Reloads the application unconditionally. */ reload(): void; /** * Reloads the application only when it is older than the last * version deployed on the server. * * @param url - URL of the file containing the last version number, usually 'index.html'. * @param pattern - Regular expression pattern for retrieving a version number. * @param group - Name of the group where the version number is stored when regular expression matches. * @param expected - Expected version number, when retrieved value is different then reload the application. */ reloadWhenNeeded(url: string, pattern: string, group: string, expected: string): void; }