Skip to content
Stateless alternatives to Combine.Subject
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Relay.xcodeproj
Resources
Sources/Relay
.gitignore
.swift-version
CombineRelay.podspec
LICENSE.md
Package.swift
README.md

README.md

Relay

A Relay is a Combine.Subject without the interface for sending completion signal.

Why

A Subject, like a Publisher, is stateful. Once the complete signal is sent, subscriber will stop receiving values. In practice, this is rarely desirable: anyone with a reference to a subject can terminate the data stream for all subscribers, and that becomes a source of bugs.

Relays take away the mutability of the "completion" state, making it safer to share.

Install

Xcode:

Add package https://github.com/dduan/Relay.git.

Swift Package Manager

.package(url: "http://github.com/dduan/Relay", from: "0.1.2")

CocoaPods:

use_frameworks!

pod "CombineRelay"

Carthage

github "dduan/Relay"

Usage

Relay provides types that thinly wraps around subject types in Combine:

Relay Combine
Relay Subject
PassthroughRelay PassthroughSubject
CurrentValueRelay CurrentValueSubject
AnyRelay AnySubject

Each type has identical interface and behavior to its Combine counterpart. Except it's impossible to send a complete signal.

License

MIT. See LICENSE.md

You can’t perform that action at this time.