Application
The Boson\Application
is the central component of the Boson and is responsible for managing the application lifecycle. It provides a single entry point for creating and managing web applications using WebView.
The application is responsible for:
Window creation and management.
WebView integration for web content display.
Application, WebView and Window event handling.
...and more
Architecturally, the application, like most key components, is divided into two "layers":
The main functionality belonging to the application itself.
Facades over methods and properties of descendants for quick access to the main internal components of the core.
Creating
To create an application, simply create a new Boson\Application
object. This will be sufficient for the vast majority of cases.
The application constructor also contains several optional arguments that you can pass explicitly if you wish.
The first optional argument is responsible for the Boson\ApplicationCreateInfo
application settings and allows you to fine-tune the application's operation.
The remaining optional parameters are responsible for passing external dependencies.
For example, the second argument takes an optional reference to an external Psr\EventDispatcher\EventDispatcherInterface
event dispatcher to which all events within the application can be delegated.
After creating the application, you will have access to the API to work with it, and after the necessary actions, the application will automatically start, unless otherwise specified.
Launching
The application can be started manually using the run()
method.
Stopping
The application can be stopped at any time using the quit()
method:
To find out if the application is running, you can use the Application::$isRunning
property, which returns true
if the application is currently running.
Identifier
The Boson\ApplicationId
is a unique identifier for each application instance. The identifier is needed to compare different applications for their equivalence.
To get application identifier use the Application::$id
property.
An identifier is a value object and contains methods for comparison and conversion to scalars.