Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dduan/Relay
Stateless alternatives to Combine.Subject
https://github.com/dduan/Relay
combine reactive-programming swiftui
Last synced: about 1 month ago
JSON representation
Stateless alternatives to Combine.Subject
- Host: GitHub
- URL: https://github.com/dduan/Relay
- Owner: dduan
- License: mit
- Created: 2019-06-22T22:16:18.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-08-07T06:35:39.000Z (over 5 years ago)
- Last Synced: 2024-03-25T15:08:24.125Z (9 months ago)
- Topics: combine, reactive-programming, swiftui
- Language: Swift
- Homepage:
- Size: 22.5 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-combine - Relay
README
# 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.`Relay`s 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](https://swift.org/package-manager)
```swift
.package(url: "http://github.com/dduan/Relay", from: "0.1.2")
```### [CocoaPods](http://cocoapods.org/):
```ruby
use_frameworks!pod "CombineRelay"
```### [Carthage](https://github.com/Carthage/Carthage)
```
github "dduan/Relay"
```## Usage
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.[Subject]: https://developer.apple.com/documentation/combine/subject
[PassthroughSubject]: https://developer.apple.com/documentation/combine/passthroughsubject
[CurrentValueSubject]: https://developer.apple.com/documentation/combine/currentvaluesubject
[AnySubject]: https://developer.apple.com/documentation/combine/anysubject## License
MIT. See `LICENSE.md`