class Activity
A class that represents a part of the application that can be activated when the user navigates to it.
class Activity extends ManagedObject
Description
The activity is one of the main architectural components of a Desk application. It represents a potential ‘place’ in the application, which can be activated and deactivated when the user navigates around.
This class provides infrastructure for path-based routing, based on the application’s navigation path (such as the browser’s current URL). However, activities can also be activated and deactivated manually, or activated immediately when added using app.addActivity().
Activities emit Active
and Inactive
change events when state transitions occur.
This class also provides a view property, which can be set to a view object. Usually, this property is set in the Activity.ready() method. Afterwards, if the activity corresponds to a full page or dialog, this method should call app methods to show the view. The view is automatically unlinked when the activity is deactivated, and the property is set to undefined.
Example
// Create an activity and activate it:
class MyActivity extends Activity {
navigationPageId = "foo";
protected ready() {
this.view = new body(); // imported from a view file
app.showPage(this.view);
}
}
app.addActivity(new MyActivity());
app.navigate("foo");
Constructor
- constructor()Creates a new activity instance.
Instance Members
- titleA user-facing name of this activity, if any.
- navigationPageIdThe page ID associated with this activity, to match the (first part of the) navigation path.
- viewThe current view, if any (attached automatically).
- formContextDefault form context used with input elements, if any.
- isActive()Returns true if this activity is currently active.
- isActivating()Returns true if this activity is inactive but currently activating.
- isDeactivating()Returns true if this activity is active but currently inactivating.
- beforeUnlink() protectedA method that’s called immediately before unlinking this activity.
- activateAsync()Activates the activity asynchronously.
- deactivateAsync()Deactivates the activity asynchronously.
- getNavigationTarget(…detail)Returns a NavigationTarget instance that refers to this activity.
- handleNavigationDetailAsync(detail, navigationController)A method that’s called after the user navigated to a particular sub-path of this activity, to be overridden if needed.
- delegateViewEvent(event) protectedDelegates events from the current view.
- navigateAsync(target) protectedHandles navigation to a provided navigation target or path, from the current activity.
- onNavigate(e) protectedHandles a
Navigate
event emitted by the current view. - findViewContent(type)Searches the view hierarchy for view objects of the provided type.
- createActiveTaskQueue(config?) protectedCreates a task queue that’s started, paused, resumed, and stopped automatically based on the state of this activity.
- observeService(id, observer?) protectedObserves a particular service by ID, until the activity is unlinked.
- ready() protectedA method that’s called on an active activity, to be overridden to create and render the view if needed.
- beforeActiveAsync() protectedA method that’s called and awaited before the activity is activated, to be overridden if needed.
- afterActiveAsync() protectedA method that’s called and awaited after the activity is activated, to be overridden if needed.
- beforeInactiveAsync() protectedA method that’s called and awaited before the activity is deactivated, to be overridden if needed.
- afterInactiveAsync() protectedA method that’s called and awaited after the activity is deactivated, to be overridden if needed.
Inherited Members
- emit(event)Emits an event, immediately calling all event handlers.
- emitChange(name?, data?)Emits a change event, an instance of ManagedChangeEvent.
- listen(handler)Adds a handler for all events emitted by this object.
- isUnlinked()Returns true if the object has been unlinked.
- unlink()Unlinks this managed object.
- attach(target, observer?) protectedAttaches the provided managed object to this object.
- autoAttach(propertyName, observer?) protectedObserves a property, so that any object assigned to it is attached immediately.