StatePropertyAccessor interface
Interface for accessing a property in state storage with type safety.
Remarks
This interface defines standard methods for working with persisted state properties, allowing property access with strong typing to reduce errors when working with complex state objects.
Methods
| delete(Turn |
Deletes the persisted property from its backing storage object. Example
|
| get(Turn |
Reads a persisted property from its backing storage object. Example
|
| get(Turn |
Reads a persisted property from its backing storage object. |
| set(Turn |
Assigns a new value to the properties backing storage object. Example
|
Method Details
delete(TurnContext)
Deletes the persisted property from its backing storage object.
Example
await myProperty.delete(context);
function delete(context: TurnContext): Promise<void>
Parameters
- context
- TurnContext
Context for the current turn of conversation with the user.
Returns
Promise<void>
Remarks
The properties backing storage object SHOULD be loaded into memory on first access.
get(TurnContext)
Reads a persisted property from its backing storage object.
Example
const value = await myProperty.get(context, { count: 0 });
function get(context: TurnContext): Promise<undefined | T>
Parameters
- context
- TurnContext
Context for the current turn of conversation with the user.
Returns
Promise<undefined | T>
Remarks
The properties backing storage object SHOULD be loaded into memory on first access.
If the property does not currently exist on the storage object and a defaultValue has been
specified, a clone of the defaultValue SHOULD be copied to the storage object. If a
defaultValue has not been specified then a value of undefined SHOULD be returned.
get(TurnContext, T)
Reads a persisted property from its backing storage object.
function get(context: TurnContext, defaultValue: T): Promise<T>
Parameters
- context
- TurnContext
Context for the current turn of conversation with the user.
- defaultValue
-
T
(Optional) default value to copy to the backing storage object if the property isn't found.
Returns
Promise<T>
set(TurnContext, T)
Assigns a new value to the properties backing storage object.
Example
await myProperty.set(context, value);
function set(context: TurnContext, value: T): Promise<void>
Parameters
- context
- TurnContext
Context for the current turn of conversation with the user.
- value
-
T
Value to assign.
Returns
Promise<void>
Remarks
The properties backing storage object SHOULD be loaded into memory on first access.
Depending on the state systems implementation, an additional step may be required to persist the actual changes to disk.