Last active
April 20, 2020 15:44
-
-
Save jasdev/776d54edcdcaf8d634cd4322cea33291 to your computer and use it in GitHub Desktop.
`ReplaySubject` with filled-in `.send(subscription:)` 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: Combine.Subscription) { | |
subscription.request(.unlimited) | |
} | |
func send(completion: Subscribers.Completion<Failure>) { /* … */ } | |
func send(_ value: Output) { /* … */ } | |
func receive<Subscriber: Combine.Subscriber>( | |
subscriber: Subscriber | |
) where Failure == Subscriber.Failure, Output == Subscriber.Input { /* … */ } | |
} | |
extension ReplaySubject { | |
final class Subscription: Combine.Subscription { | |
func request(_ demand: Subscribers.Demand) { /* … */ } | |
func cancel() { /* … */ } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment