BotStateSet class

A collection of BotState plugins that should be loaded or saved in parallel as a single unit. See AutoSaveStateMiddleware for an implementation of this class.

Constructors

BotStateSet(BotState[])

Creates a new BotStateSet instance.

Properties

botStates

Array of the sets BotState plugins.

Methods

add(BotState[])

Registers one or more BotState plugins with the set.

loadAll(TurnContext, boolean)

Calls BotState.load() on all of the BotState plugins in the set.

saveAllChanges(TurnContext, boolean)

Calls BotState.saveChanges() on all of the BotState plugins in the set.

Constructor Details

BotStateSet(BotState[])

Creates a new BotStateSet instance.

new BotStateSet(botStates: BotState[])

Parameters

botStates

BotState[]

One or more BotState plugins to register.

Property Details

botStates

Array of the sets BotState plugins.

botStates: BotState[]

Property Value

Method Details

add(BotState[])

Registers one or more BotState plugins with the set.

function add(botStates: BotState[]): this

Parameters

botStates

BotState[]

One or more BotState plugins to register.

Returns

this

The updated BotStateSet.

loadAll(TurnContext, boolean)

Calls BotState.load() on all of the BotState plugins in the set.

function loadAll(context: TurnContext, force?: boolean): Promise<void>

Parameters

context
TurnContext

Context for current turn of conversation with the user.

force

boolean

(Optional) If true the cache will be bypassed and the state will always be read in directly from storage. Defaults to false.

Returns

Promise<void>

Remarks

This will trigger all of the plugins to read in their state in parallel.

await stateSet.readAll(context);

saveAllChanges(TurnContext, boolean)

Calls BotState.saveChanges() on all of the BotState plugins in the set.

function saveAllChanges(context: TurnContext, force?: boolean): Promise<void>

Parameters

context
TurnContext

Context for current turn of conversation with the user.

force

boolean

(Optional) if true the state will always be written out regardless of its change state. Defaults to false.

Returns

Promise<void>

Remarks

This will trigger all of the plugins to write out their state in parallel.

await stateSet.saveAllChanges(context);