Placement
Overview
Object representing a Rokt placement loaded on a page. Provides functionality to interact with the placement on a page.
Methods
close
▸ close(): Promise<void>
Closes and removes the placement from the page.
Returns: Promise<void>
on
▸ on<T>(event
: string): Subscriber<PlacementEvent<T>>
Allows subscribing to events with a specific name coming from a placement.
Parameters:
Name | Type | Description |
---|---|---|
event | string | Name of the event to subscribe to |
Returns: Subscriber<T>
ready
▸ ready(): Promise<T>
Allows waiting for a placement to be ready. Readiness is defined as:
- placement has loaded successfully
- placement is ready to receive events sent using the send method.
If for any reason a placement fails to be loaded, the promise is going to be rejected with an error.
Returns: Promise<void>
send
▸ send<T>(name
: string, data
?: T): Promise<void>
Sends an event to the placement. Returned promise will be resolved once placement handles the message.
Parameters:
Name | Type | Description |
---|---|---|
name | string | Name of the event |
data | T | Optional payload for a given event |
Returns: Promise<void>