combine-reactive_skill

This skill guides you to choose between Combine and async/await, design robust operator chains, and prevent memory leaks in reactive streams.
  • Shell

6

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill kaakati/rails-enterprise-dev --skill combine-reactive

  • SKILL.md11.4 KB

Overview

This skill codifies expert decision-making for Combine in iOS/tvOS projects. It helps you choose between Combine and async/await, pick the right Subject, design operator chains, and avoid common memory and threading pitfalls. Use it when implementing reactive streams, bridging to async APIs, or troubleshooting leaks and race conditions.

How this skill works

The skill inspects your data-flow pattern and maps it to a recommendation: single one-shot tasks favor async/await while continuous or UI-driven streams favor Combine. It evaluates Subject needs (CurrentValueSubject vs PassthroughSubject), suggests operator selections (map, flatMap, debounce, combineLatest, etc.), and enforces subscription and threading best practices to prevent retain cycles and race conditions. It also provides bridging patterns to convert Publishers to async functions and patterns for exposing publishers safely.

When to use it

  • Deciding between Combine and async/await for a feature
  • Designing a UI-driven stream (search, input throttling, live filtering)
  • Combining multiple publishers from different sources
  • Debugging memory leaks or retain cycles involving AnyCancellable and sink
  • Implementing an event bus or pub/sub boundaries
  • Bridging Combine publishers into async/await codepaths

Best practices

  • Prefer async/await for single, one-shot async operations to avoid cancellable management
  • Use CurrentValueSubject only when synchronous access to current value is required; use PassthroughSubject for event streams
  • Never expose subjects directly; expose AnyPublisher to preserve encapsulation
  • Always store subscriptions in a Set<AnyCancellable> and use [weak self] in closures to avoid retain cycles
  • Schedule timing operators on the appropriate scheduler and receive on Main for UI updates
  • Use map for simple transforms and flatMap only when working with nested publishers

Example use cases

  • Debounced search box: $searchText.debounce(...).flatMap { searchService.search(...) }
  • EventBus for cross-module communication exposing AnyPublisher channels
  • Combining user profile and settings streams with combineLatest to update UI state
  • Converting an existing Publisher-returning API into an async function with withCheckedThrowingContinuation
  • Diagnosing a ViewModel that never deallocates by checking stored AnyCancellable and assign(to:on:) usage

FAQ

Migrate when flows are simple one-shot calls and the migration cost is low; keep Combine where you rely on continuous streams, advanced operators, or existing architecture consistency.

How do I avoid race conditions when sending on a Subject?

Serialize sends through a dedicated serial DispatchQueue or ensure delivery on a single scheduler with receive(on:). Never send concurrently from multiple threads.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational