Skip to content

Instantly share code, notes, and snippets.

@hermanbanken
Last active June 5, 2019 05:43
Show Gist options
  • Select an option

  • Save hermanbanken/91b45737a58dc0663b8a91d5c2fd0024 to your computer and use it in GitHub Desktop.

Select an option

Save hermanbanken/91b45737a58dc0663b8a91d5c2fd0024 to your computer and use it in GitHub Desktop.
struct MyPublisher : Publisher {
public typealias Failure = Error
public typealias Output = Int
@available(iOS 13.0, *)
public func receive<S>(subscriber: S) where S : Subscriber, Failure == S.Failure, Output == S.Input {
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(2), execute: {
_ = subscriber.receive(42)
subscriber.receive(completion: .finished)
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment