Application

class Application

extends Component

Represents the application itself, encapsulates activities (AppActivity components) and contexts for rendering and activation using URL-like paths.

Use the static run method to create and activate an application using a set of activity constructors, or create an application class that includes activities as (preset) bound components.

Note: Do not use the Application class directly, as it will not initialize rendering or activation contexts. Instead, use platform specific application classes such as BrowserApplication that is exported by the @typescene/webapp package.

Constructor

(): Application

.run() static

<T extends Application>(this: typeof Application, ...activities: ComponentConstructor<AppActivity>[]): T

Create an application that includes given activities, and start it immediately. If none of the activities has a path property, then all activities are activated immediately; otherwise each activity will activate itself using the current activationContect.

Returns: the application instance.

Note: Calling this method directly on Application creates an application without any context (i.e. activationContext and renderContext). Instead, use a constructor that is meant for a specific platform (e.g. BrowserApplication).

.active static

ManagedList<Application>

All Application instances that are currently active.

.setAutoUpdateHandler() static

<T extends ComponentConstructor<Component>>(f: (module: any, C: T, methodName: string & keyof T) => void): void

Set a handler that is used to register classes and modules for automatic update/reload; this method is used by e.g. @typescene/webapp to support Hot Module Reload.

.registerAutoUpdate() static

<T extends ComponentConstructor<Component>>(module: any, C: T, methodName: string & keyof T): void

Register given class and module for automatic update/reload; this method is used by e.g. ViewActivity and should not be used on its own.

.name

string

The application name.

.activities

AppActivityList

List of root activities, as child components.

.renderContext

UIRenderContext

Application render context as a managed child object, propagated to all (nested) AppComponent instances. This object is set by specialized application classes such as BrowserApplication to match the capabilities of the runtime platform.

.activationContext

AppActivationContext

Activity activation context as a managed child object, propagated to all (nested) AppComponent instances. This object is set by specialized application classes such as BrowserApplication to match the capabilities of the runtime platform.

.activate()

(): this

Activate this application asynchronously, immediately creating all primary activities; any errors during activation are handled by logging them to the console (uses UnhandledErrorEmitter).

Returns: the application itself.

.activateAsync()

(): Promise<void>

Activate this application, immediately creating all primary activities.

.deactivateAsync()

(): Promise<void>

Deactivate this application, immediately destroying all actvities.

.destroyAsync()

(): Promise<void>

Destroy this application, immediately destroying all activities.

.navigate()

(path: string): this

Navigate to given (relative) path using the current Application.activationContext.

.goBack()

(): this

Go back to the previous navigation path, if implemented by the current Application.activationContext.

.add()

(...activities: AppActivity[]): this

Add given activities to the application. Activities with matching paths will be activated immediately (see AppActivity.path).

.showViewActivityAsync()

<TViewActivity extends AppActivity & { render: Function; }>(viewActivity: TViewActivity): Promise<TViewActivity>

Add given view activity to the application, and activate it immediately regardless of AppActivity.path; this causes corresponding views to be rendered if possible.

Returns: A promise that resolves to the view activity after it has been activated.

.findService()

(name: string): ManagedService

Returns the currently registered service with given name, if any. This is an alias of ManagedService.find().

.isPresetComponent() protected

(): boolean

Inherited from Component.isPresetComponent.

.delegateEvent() protected

(e: ManagedEvent, propertyName: string): boolean | void

Inherited from Component.delegateEvent.

.getParentComponent()

<TParent extends Component = Component>(ParentClass?: ComponentConstructor<TParent>): TParent

Inherited from Component.getParentComponent.

.getBoundParentComponent()

<TParent extends Component>(ParentClass?: ComponentConstructor<TParent>): TParent

Inherited from Component.getBoundParentComponent.

.emitAction()

(name: string, inner?: ManagedEvent, context?: ManagedObject): void

Inherited from Component.emitAction.

.propagateComponentEvent() deprecated

(name: string, inner?: ManagedEvent): void

Inherited from Component.propagateComponentEvent.

.managedId

number

Inherited from ManagedObject.managedId.

.managedState

ManagedState

Inherited from ManagedObject.managedState.

.getReferenceCount() protected

(): number

Inherited from ManagedObject.getReferenceCount.

.getManagedReferrers() protected

(): ManagedObject[]

Inherited from ManagedObject.getManagedReferrers.

.getManagedParent() protected

<TParent extends ManagedObject = ManagedObject>(ParentClass?: ManagedObjectConstructor<TParent>): TParent

Inherited from ManagedObject.getManagedParent.

.emit()

<TEvent extends ManagedEvent = ManagedEvent, TConstructorArgs extends any[] = any[]>(e: string | TEvent | (new (...args: TConstructorArgs) => TEvent), ...constructorArgs: TConstructorArgs): this

Inherited from ManagedObject.emit.

.emitChange()

(name?: string): void

Inherited from ManagedObject.emitChange.

.propagateChildEvents() protected deprecated

(...types: ((new (...args: any[]) => ManagedEvent) | ((e: ManagedEvent) => any))[]): this

Inherited from ManagedObject.propagateChildEvents.

.activateManagedAsync() protected

(): Promise<any>

Inherited from ManagedObject.activateManagedAsync.

.deactivateManagedAsync() protected

(): Promise<void>

Inherited from ManagedObject.deactivateManagedAsync.

.destroyManagedAsync() protected

(): Promise<void>

Inherited from ManagedObject.destroyManagedAsync.

.onManagedStateActivatingAsync() protected

(): Promise<void>

Inherited from ManagedObject.onManagedStateActivatingAsync.

.onManagedStateActiveAsync() protected

(): Promise<void>

Inherited from ManagedObject.onManagedStateActiveAsync.

.onManagedStateDeactivatingAsync() protected

(): Promise<void>

Inherited from ManagedObject.onManagedStateDeactivatingAsync.

.onManagedStateInactiveAsync() protected

(): Promise<void>

Inherited from ManagedObject.onManagedStateInactiveAsync.

.onManagedStateDestroyingAsync() protected

(): Promise<void>

Inherited from ManagedObject.onManagedStateDestroyingAsync.


Application.Presets

Application presets type, for use with Component.with.

.name

string

Human readable application name.

.renderContext

UIRenderContext

Platform dependent application render context.

.activationContext

AppActivationContext

Platform dependent activation context (router).