Last active
April 20, 2020 15:40
-
-
Save jasdev/bc1577fc1eaecc1559f1ab3e44f8206c to your computer and use it in GitHub Desktop.
`ReplaySubject` with `Publisher` requirement.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class ReplaySubject<Output, Failure: Error>: Subject { | |
typealias Output = Output | |
typealias Failure = Failure | |
private let bufferSize: Int | |
init(bufferSize: Int) { | |
self.bufferSize = bufferSize | |
} | |
func send(subscription: Subscription) { /* … */ } | |
func send(completion: Subscribers.Completion<Failure>) { /* … */ } | |
func send(_ value: Output) { /* … */ } | |
func receive<Subscriber: Combine.Subscriber>( /// (1) The compiler’s generated method stub unfortunately picks | |
/// `S` for the `Subscriber` generic. And I tend to prefer the fuller name, even though it requires a | |
/// `Combine.Subscriber` disambiguation. Declarative programming is hard enough as it is and throwing | |
/// single-letter generics at folks only makes it tougher. | |
/// | |
/// Back when, Rx did the same and promoted all generics to full words in the 5.x release. See the | |
/// “Generic Renames Checklist” section of [this issue](https://github.com/ReactiveX/RxSwift/issues/1921#issue-430354614) | |
/// for details. | |
/// | |
/// This method is the attachment point for subscribers to this subject. We’ll need to make sure | |
/// `Subscriber.Failure` and `.Input` match `Failure` and `Output`, respectively. | |
subscriber: Subscriber | |
) where Failure == Subscriber.Failure, Output == Subscriber.Input { /* … */ } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment