Documentation

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.

Example

export class MyActivity extends AppActivity {
  path = "/";

  async onManagedStateActiveAsync() {
    await super.onManagedStateActiveAsync();
    console.log("MyActivity is now active");
    // not associated with a view
  }
}

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).

.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 activateAsync.

.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, 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, and can be overridden to validate the captured path segments before activation.

.deactivateAsync()

(): Promise<void>

Deactivate this activity.

.destroyAsync()

(): Promise<void>

Destroy this activity.

.isActive()

(): boolean

Returns true if this activity is currently active.

.deactivated

number

The time (result of Date.now()) when this activity was last deactivated; or undefined if this activity has never been deactivated.

.renderContext

UIRenderContext

Inherited from AppComponent.renderContext.

.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.