swift-async-stream-patterns

Installation
SKILL.md

AsyncStream & AsyncSequence Patterns

When to use

  • Building custom AsyncSequence types that produce values over time
  • Bridging synchronous/callback-based APIs to async/await
  • Implementing channels, buffers, or multi-consumer broadcasting
  • Handling backpressure in producer/consumer scenarios
  • Creating "CurrentValue"-like semantics where late subscribers receive buffered values

Core Patterns from swift-async-algorithms

1. State Machine Pattern

Use explicit state machines with enums to model complex async behavior. State machines return actions rather than performing side effects directly. This separates state logic from async operations.

struct ChannelStateMachine<Element: Sendable> {
  private enum State: Sendable {
Related skills
Installs
6
GitHub Stars
12
First Seen
Feb 10, 2026