swiftzilla/skills

swift_combine

Swift Combine framework for reactive programming, handling asynchronous events with publishers, subscribers, and operators.

First seen Jan 28, 2026

Installation

$ npx skills add swiftzilla/skills --skill swift_combine

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from swiftzilla/skills · top by installs.

npx skills add swiftzilla/skills

Browse all from swiftzilla/skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 7
License Proprietary
Default branch main
Open issues 1
Status Active

Skill metadata

Parsed from SKILL.md frontmatter.

Version1.0
LicenseProprietary
CompatibilityiOS 13+, macOS 10.15+
More metadata
version
1.0
author
SwiftZilla
website
https://swiftzilla.dev

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 2,997 B
  • docs SUMMARY.md 144 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 33 installs

SKILL.md

Swift Combine

This skill covers Apple's Combine framework for reactive programming and handling asynchronous events.

Overview

Combine is a declarative Swift API for processing values over time. It provides a unified approach to handling asynchronous events, user interface updates, and data streams.

Available References

  • [Publishers & Subscribers](./references/publishers_subscribers.md) - Core concepts and lifecycle
  • [Operators](./references/operators.md) - Transforming, filtering, and combining streams
  • [Integration](./references/integration.md) - Using Combine with UIKit, SwiftUI, and Foundation

Quick Reference

Basic Publisher

import Combine

// Published property
@Published var username: String = ""

// CurrentValueSubject
let subject = CurrentValueSubject<String, Never>("initial")

// PassthroughSubject
let passthrough = PassthroughSubject<Int, Never>()

// Just publisher
let just = Just("value")

// Future publisher
let future = Future<String, Error> { promise in
    promise(.success("result"))
}

Subscribing

// Sink
let cancellable = publisher.sink(
    receiveCompletion: { completion in
        switch completion {
        case .finished:
            print("Completed")
        case .failure(let error):
            print("Error: \(error)")
        }
    },
    receiveValue: { value in
        print("Value: \(value)")
    }
)

// Assign
let cancellable = publisher
    .assign(to: \.text, on: label)

Storing Subscriptions

private var cancellables = Set<AnyCancellable>()

publisher
    .sink { value in
        print(value)
    }
    .store(in: &cancellables)

Common Operators

publisher
    .filter { $0 > 0 }
    .map { $0 * 2 }
    .debounce(for: .seconds(0.5), scheduler: RunLoop.main)
    .removeDuplicates()
    .sink { value in
        print(value)
    }

Combine vs Async/Await

Use Case Combine Async/Await
Event streams ✅ Excellent ⚠️ Complex
UI bindings ✅ Perfect ⚠️ Verbose
Chaining operations ✅ Great ✅ Good
Simple async calls ⚠️ Overkill ✅ Simple
Error handling ✅ Rich ✅ Good

Best Practices

  1. Store cancellables - Prevent memory leaks
  2. Use weak self - Avoid retain cycles
  3. Handle errors - Always handle completion
  4. Thread safety - Use receive(on:) for UI
  5. Cancel properly - Clean up subscriptions
  6. Avoid overuse - Combine is powerful but not for everything
  7. Test pipelines - Use expectations for async

For More Information

Visit https://swiftzilla.dev for comprehensive Combine documentation.