AppActivity

class AppActivity

extends AppComponent

Activity base class. Represents a component of an application, which can be activated and deactivated independently. Can be used for activities that are activated independently of the UI; otherwise refer to any of the ViewActivity classes. Activities are usually preset on the Application constructor instead of being constructed independently, except when necessary to facilitate ‘lazy’ loading of parts of the application code.

Constructor

(name?: string, path?: string): AppActivity

.name

string

Optional human readable name for this activity.

.path

string

Optional activation path; if set to a string, this activity is automatically activated and deactivated asynchronously, depending on the current target path (e.g. URL path, handled by a platform dependent AppActivationContext instance). This string may contain segments such as ‘:id’ or ‘*name’ to capture variable parts of the path; when matched, these parts are stored in the object referenced by the match property.

.match

Readonly<MatchedPath>

The path segments that were captured last based on the target path, as matched by the AppActivationContext, for a path such as foo/bar/:id, foo/*name, or ./:id. This property is set when the activity is activated through the activateAsync method.

.getParentActivity()

(): AppActivity

Returns the activity instance that contains a managed child reference that (indirectly) points to this activity instance.

.getApplication()

(): Application

Returns the parent application that contains this activity, if any.

.activateAsync()

(match?: MatchedPath): Promise<void>

Activate this activity, optionally based on given captured path segments (returned by AppActivationContext.match, for a path such as foo/bar/:id, foo/*name, or ./:id). This method is called automatically when the activity path matches the current target path, but may also be called directly. This method can be overridden to validate the captured path segments before activation.

.destroyAsync()

(): Promise<void>

Destroy this activity.

.isActive()

(): boolean

Returns true if this activity is currently active.

.activated

number

The timestamp (result of Date.now()) corresponding to the moment this activity was last activated; or undefined if this activity has never been activated.

.deactivated

number

The timestamp (result of Date.now()) corresponding to the moment this activity was last deactivated; or undefined if this activity has never been deactivated.

.renderContext

UIRenderContext

Inherited from AppComponent.renderContext.

.viewportContext

any

Inherited from AppComponent.viewportContext.

.activationContext

AppActivationContext

Inherited from AppComponent.activationContext.


AppActivity.Presets

Activity presets type, for use with Component.with.

.name

string

Human readable name for this activity.

.path

string

(Partial) activation path, see AppActivity.path.