A Relay
is a Combine.Subject
without the interface for sending completion
signal.
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.
Relay
s take away the mutability of the "completion" state, making it safer to
share.
Add package https://github.com/dduan/Relay.git
.
.package(url: "http://github.com/dduan/Relay", from: "0.1.2")
use_frameworks!
pod "CombineRelay"
github "dduan/Relay"
Relay provides types that thinly wraps around subject types in Combine:
Relay | Combine |
---|---|
Relay | Subject |
PassthroughRelay | PassthroughSubject |
CurrentValueRelay | CurrentValueSubject |
Each type has identical interface and behavior to its Combine counterpart. Except it's impossible to send a complete signal.
MIT. See LICENSE.md
link |
Stars: 5 |
Last commit: 4 years ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics