Application
Role
- An
Application
is a singleton, - The
Application
handles the bootstrap of current application, - Current
Application
is initialized in the file app.js (i.e. bootstrap), - Any
Application
can have a name, - Every project must declare an implementation of the
Application
class.
Declaration
import $Application from "@Application";
/**
* MyApplication example
*
* @name MyApplication
* @class
* @extends Application
*/
export default $Application.declare("app", {
properties: {
name: "myAppName"
}
},
methods: {
/**
* Extension point that is called right after the application has been initialized.
* You should rarely need to implement it.
*/
initialize: function() {},
/**
* Extension point that is called when the application is ready to be shown.
* The first screen is not yet shown.
* This is the right place to initialize services, player, get data, etc.
*/
beforeShow: function() {}
}
);
The application code offers extension points to add behaviours into the startup sequence. Most of the time, you will only need to implement the beforeShow()
method.
Expected use
Events
Events triggered by the Application
are defined in const ApplicationEvents
. By default, Application
subscribes to:
suspend
eventresume
eventquit
event
You can add any needed event (to subscribe to) by adding its subscription into the main application constructor:
import $Application from "@Application";
import $EventBus from "@EventBus";
import $ApplicationEvents from "@ApplicationEvents";
/**
* App
*
* @name app
* @extends Application
*
* @property {string} name - Application name
* @property {EventBus} eventBus - Instance of EventBus
*
* @class
*/
export default $Application.declare("app", {
properties: /** @lends app.prototype */ {
name: "app",
eventBus: {class: $EventBus}
},
constructor: function () {
this.eventBus.subscribe($ApplicationEvents.ready, () => {
console.debug("Application ready");
});
}
});
Lifecycle
The application is the starting point of everything.
When an application is started, the following promises are chained sequentially:
Framework initialization
The whole Dana framework code is started by the file named wtv.js which handles those startup steps:
Application boot up sequence
During the application startup, those specific methods will be called and various events will be fired:
API Reference
This application component is part of Dana’s core vendor which includes a JSDoc description.
See the component AbstractApplication
under this core API.