Stage
The place where Actors perform.
In more technical terms, the Stage is the main event bus propagating DomainEvents to Actors it instantiates and StageCrewMembers that have been registered with it.
Constructor Summary
Public Constructor | ||
public |
constructor(cast: Cast, manager: StageManager) |
Member Summary
Public Members | ||
public |
cast: * |
Method Summary
Public Methods | ||
public |
Instantiates a new Actor or fetches an existing one by their name if they've already been instantiated. |
|
public |
announce(event: DomainEvent): void Notifies all the assigned listeners of the event. |
|
public |
assign(listeners: ListensToDomainEvents[]): void Assigns listeners to be notified of DomainEvents emitted via Stage#announce |
|
public |
Generates and remembers a CorrelationId for the current Activity. |
|
public |
Generates and remembers a CorrelationId for the current scene. |
|
public |
Returns the CorrelationId for the current Activity. |
|
public |
Returns the CorrelationId for the current scene. |
|
public |
Returns current time. |
|
public |
Configures the Stage to prepare Actors instantiated via Stage#actor using the provided Cast. |
|
public |
theActorCalled(name: string): Actor An alias for Stage#actor |
|
public |
Returns the last Actor instantiated via Stage#actor. |
|
public |
theShowHasStarted(): boolean Returns {true} if there is an Actor in the spotlight, {false} otherwise. |
|
public |
waitForNextCue(): Promise<void> Returns a Promise that will be resolved when any asynchronous post-processing activities performed by Serenity/JS are completed. |
Public Constructors
public constructor(cast: Cast, manager: StageManager) source
Params:
Name | Type | Attribute | Description |
cast | Cast | ||
manager | StageManager |
Public Members
public cast: * source
Public Methods
public actor(name: string): Actor source
Instantiates a new Actor or fetches an existing one by their name if they've already been instantiated.
Params:
Name | Type | Attribute | Description |
name | string | case-sensitive name of the Actor |
Tests:
- Stage provides both the more verbose and more concise way of accessing the actors
- Stage when instantiating actors instantiates a new actor when their name is called for the first time
- Stage when instantiating actors returns an existing actor if it has already been instantiated before
- Stage when referencing a recently retrieved actor retrieves the current actor, if there is any
- Stage when an error occurs complains if the Cast does not provide a way to instantiate a given actor
- Stage when an error occurs complains if the Cast does not provide a way to prepare a given actor and mentions the type of the Cast, when available
- Stage when an error occurs complains if the Cast throws an error during actor instantiation
- Stage when an error occurs complains if the Cast throws an error during actor instantiation and mentions the type of the Cast, when available
public announce(event: DomainEvent): void source
Notifies all the assigned listeners of the event.
Params:
Name | Type | Attribute | Description |
event | DomainEvent |
Returns:
void |
Listens:
public assign(listeners: ListensToDomainEvents[]): void source
Assigns listeners to be notified of DomainEvents emitted via Stage#announce
Params:
Name | Type | Attribute | Description |
listeners | ListensToDomainEvents[] |
Returns:
void |
public assignNewActivityId(): CorrelationId source
Generates and remembers a CorrelationId for the current Activity.
This method should be used in custom test runner adapters when instantiating an ActivityStarts event.
public assignNewSceneId(): CorrelationId source
Generates and remembers a CorrelationId for the current scene.
This method should be used in custom test runner adapters when instantiating a SceneStarts event.
public currentActivityId(): CorrelationId source
Returns the CorrelationId for the current Activity.
public currentTime(): Timestamp source
Returns current time. This method should be used whenever DomainEvent objects are instantiated by hand.
public engage(actors: Cast): void source
Configures the Stage to prepare Actors instantiated via Stage#actor using the provided Cast.
Params:
Name | Type | Attribute | Description |
actors | Cast |
Returns:
void |
public theActorCalled(name: string): Actor source
An alias for Stage#actor
Params:
Name | Type | Attribute | Description |
name | string |
See:
public theActorInTheSpotlight(): Actor source
Returns the last Actor instantiated via Stage#actor. Useful when you don't can't or choose not to reference the actor by their name.
Throws:
if no {Actor} has been activated yet |
Tests:
- Stage when referencing a recently retrieved actor provides both the more verbose and more concise way of accessing the actors in the spotlight
- Stage when referencing a recently retrieved actor provides both the more verbose and more concise way of accessing the actors in the spotlight
- Stage when referencing a recently retrieved actor
- Stage when referencing a recently retrieved actor
public theShowHasStarted(): boolean source
Returns {true} if there is an Actor in the spotlight, {false} otherwise.
Returns:
boolean |
public waitForNextCue(): Promise<void> source
Returns a Promise that will be resolved when any asynchronous post-processing activities performed by Serenity/JS are completed.
Returns:
Promise<void> |