From Bright Pattern Documentation
(Created page with "<translate> =onAgentStateChange= This handler will be invoked when the state of the agent changes. ==Request== ''Syntax'' {| class="wikitable" |on('ON_AGENT_STATE_CHANGE',...") |
(Updated via BpDeleteTranslateTags script) |
||
Line 1: | Line 1: | ||
− | + | ||
=onAgentStateChange= | =onAgentStateChange= | ||
Line 63: | Line 63: | ||
(None) | (None) | ||
− | |||
− | |||
− | |||
− |
Latest revision as of 04:01, 29 May 2024
• 5.19
onAgentStateChange
This handler will be invoked when the state of the agent changes.
Request
Syntax
on('ON_AGENT_STATE_CHANGE', handler: OnAgentStateChangeHandler): void
|
Parameters
Parameter | Parameter Values | Data Type | Optional/Required | Description |
state | String | Required | The agent’s state, can be any of the following:
| |
notReadyReason | String | Optional | The reason why the agent is "not_ready" now. Note that this parameter is present only when the state is not_ready |
Example
let currentAgentState: AgentState | undefined = undefined;
let currentAgentNotReadyReason: string | undefined = undefined;
function agentStateChangeCallback(newState: AgentState, notReadyReason?: string) {
console.log("Agent state has been changed!");
currentAgentState = newState;
currentAgentNotReadyReason = notReadyReason;
}
adApi.on("ON_AGENT_STATE_CHANGE", agentStateChangeCallback);
Return Value
(None)