ADK for TypeScript: API Reference
    Preparing search index...

    Class State

    A state mapping that maintains the current value and the pending-commit delta.

    Constructors

    • Parameters

      • value: Record<string, unknown> = {}

        The current value of the state.

      • delta: Record<string, unknown> = {}

        The delta change to the current value that hasn't been committed.

      Returns State

    Properties

    APP_PREFIX: "app:" = 'app:'
    TEMP_PREFIX: "temp:" = 'temp:'
    USER_PREFIX: "user:" = 'user:'

    Methods

    • Returns the value of the state dict for the given key.

      Type Parameters

      • T

      Parameters

      • key: string

        The key to get the value for.

      • OptionaldefaultValue: T

        The default value to return if the key is not found.

      Returns T | undefined

      The value of the state for the given key, or the default value if not found.

    • Whether the state has pending delta.

      Parameters

      • key: string

      Returns boolean

    • Whether the state has pending delta.

      Returns boolean

    • Sets the value of the state dict for the given key.

      Parameters

      • key: string

        The key to set the value for.

      • value: unknown

        The value to set.

      Returns void

    • Returns the state as a plain JSON object.

      Returns Record<string, unknown>

    • Updates the state dict with the given delta.

      Parameters

      • delta: Record<string, unknown>

        The delta to update the state with.

      Returns void