The Project Context module is a key part of the Customer Success module framework which establishes a container for project dependencies and a system for other modules to await certain dependencies before completing their own initialization process.
Table of Contents |
---|
The Project Context Object
When included in a project, the Project Context module will establish an object in the global context at projects.<The Orbita project ID>:
...
Info |
---|
The object is actually a proxy that prevents overwriting the base properties and assists with notifying subscribers awaiting dependencies when those dependencies have been initialized. |
Anchor | ||||
---|---|---|---|---|
|
The experience designer flow revision ID at the time the project context was created, used to determine staleness.
isStale (hidden, established by proxy)
isStale will be true if the context is considered stale (determined by comparing the context revision ID to the current experience designer revision ID), false otherwise.
id
The ID of the Orbita project that the context belongs to.
host
The current Orbita environment host.
environmentName
The current Orbita environment name (the first segment of the host).
version
The version of Orbita that the environment is running on.
Anchor | ||||
---|---|---|---|---|
|
The assumed tier (“dev”, “stage”, or “prod”) based on the presence of the word “sandbox” or a suffix of “-dev” or “-stage” in the host.
Anchor | ||||
---|---|---|---|---|
|
Parameters:
dependencies (string or array of strings): One or more keys of dependencies to await
Returns: A promise that resolves when all awaited dependencies have been initialized.
Getting the Project Context
Modules and other project code dependent on the project context should obtain it upon initialization using the following code:
...
Check if the projects object exists in the global context
If not, create it
Check for a deferred promise placeholder
If one exists, create a new project context, replace the placeholder with it, and resolve the deferred promise
If there is no placeholder, and there is either no existing context, or the existing context is stale, create a new project context
Awaiting Dependencies
After getting the project context, dependencies can be awaited with code such as:
...
Get the project context from the reference in the flow context.
Call awaitDependencies, passing it the names of any dependencies required
Once those dependencies are available, the promise returned by awaitDependencies will be resolved with an object containing references to all resolved dependencies (references will also be added to the project context object).
Invoke any subsequent nodes (which presumably contain code dependent on the awaited dependencies)
Initializing Dependencies
Dependencies are initialized simply by setting a property with the module key on the project context object:
...