Skip to content

Stage 4: Document async/await + optional UniTask integration#298

Open
MaxHeimbrock wants to merge 1 commit into
max/yield-instruction-async-enumerablefrom
max/unitask-docs
Open

Stage 4: Document async/await + optional UniTask integration#298
MaxHeimbrock wants to merge 1 commit into
max/yield-instruction-async-enumerablefrom
max/unitask-docs

Conversation

@MaxHeimbrock

Copy link
Copy Markdown
Contributor

Summary

Capstone of the UniTask migration. Adds a README section, "Asynchronous programming: coroutines, async/await, and UniTask", documenting the three interchangeable async styles the SDK now supports, and states the forward policy.

Policy (decided): keep both, no deprecation. Coroutines (yield return) remain the default and fully supported; async/await and UniTask are purely additive opt-ins. The coroutine API is not deprecated and no removal is planned — any future change would go through a deprecation cycle.

What the new section documents

  1. Coroutines — the default (already shown throughout the README).
  2. async/await, no dependency — every instruction is awaitable (Stage 1 GetAwaiter); inspect IsError on the instruction, await does not throw (parity with yield return); continuations resume on the main thread. Includes the async void caveat for event handlers.
  3. UniTask, optional — install com.cysharp.unitask; the LIVEKIT_UNITASK define auto-enables the LiveKit.UniTask assembly. Examples: AsUniTask(cancellationToken) (Stage 2), UniTask.WhenAll(...) parallel publish, and await foreach over reader.ReadIncremental().AsAsyncEnumerable(ct) with the StreamError throw-on-error contract (Stage 3). Points to the Meet sample (UniTask) and Basic sample (coroutines).

Notes

  • Docs-only: one file (README.md, +56 lines). No code, no [Obsolete], no sample/scene changes, no version bump (releases use GitHub-generated notes).
  • Snippets use the verified public signatures: Connect(url, token, RoomOptions), PublishTrack(track, options), ReadIncremental().AsAsyncEnumerable(). (The README's pre-existing 2-arg Connect example is stale and left untouched as out of scope.)

Targeting

Base branch is max/yield-instruction-async-enumerable (Stage 3, PR #297) so the documented API matches the full shipped surface. Chain: Stage 1 (#289) → Stage 2 (#290) → Stage 3 (#297) → Stage 4 (this).

Test plan

  • Snippets cross-checked against the public API in Runtime/Scripts/ (Connect/PublishTrack overloads, AsUniTask, AsAsyncEnumerable, StreamError).
  • Reviewer: eyeball the rendered README section on GitHub.

🤖 Generated with Claude Code

Stage 4 (capstone) of the UniTask migration. Adds a README section covering
the three interchangeable async styles the SDK now supports, and states the
policy: coroutines remain the default and fully supported; async/await and
UniTask are additive opt-ins; the coroutine API is not deprecated.

- async/await with no dependency (instructions are awaitable; inspect IsError,
  await does not throw — parity with yield return).
- UniTask opt-in (com.cysharp.unitask + LIVEKIT_UNITASK): AsUniTask with
  CancellationToken, UniTask.WhenAll composition, and AsAsyncEnumerable for
  await foreach over incremental streams (throws StreamError on error EoS).

Examples use the verified public signatures (Connect(url, token, RoomOptions),
PublishTrack(track, options), ReadIncremental().AsAsyncEnumerable()) and point
to the Meet sample (UniTask) and Basic sample (coroutines) as references.
Docs-only; no code, no deprecation, no version bump.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant