Restate Typescript SDK
    Preparing search index...
    • Create a context-local storage slot.

      The returned handle's get/set read and write a bag scoped to the current invocation (execute call) and shared by every fiber under it. Each contextLocal() call mints an independent slot — two handles never collide, even with the same value type.

      Minting is pure (it allocates a unique key and captures the default), so a slot can be defined at module scope and reused across invocations; only get/set touch the current fiber.

      Type Parameters

      • T

      Parameters

      • defaultValue: T

      Returns ContextLocal<T>

      A required value with a default
      const region = contextLocal("us-east-1"); // ContextLocal<string>
      // inside a handler:
      region.set("eu-west-1");
      const r = region.get(); // string
      An optional value (no default)
      const traceId = contextLocal<string>(); // ContextLocal<string | undefined>
      const t = traceId.get(); // string | undefined
    • Create a context-local storage slot.

      The returned handle's get/set read and write a bag scoped to the current invocation (execute call) and shared by every fiber under it. Each contextLocal() call mints an independent slot — two handles never collide, even with the same value type.

      Minting is pure (it allocates a unique key and captures the default), so a slot can be defined at module scope and reused across invocations; only get/set touch the current fiber.

      Type Parameters

      • T

      Returns ContextLocal<T | undefined>

      A required value with a default
      const region = contextLocal("us-east-1"); // ContextLocal<string>
      // inside a handler:
      region.set("eu-west-1");
      const r = region.get(); // string
      An optional value (no default)
      const traceId = contextLocal<string>(); // ContextLocal<string | undefined>
      const t = traceId.get(); // string | undefined