Created
May 20, 2021 19:52
-
-
Save Nillerr/54f644ee165f22ee79ba8fa730b8f163 to your computer and use it in GitHub Desktop.
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
import Combine | |
import Foundation | |
import shared | |
typealias OnEach<Output> = (Output) -> Void | |
typealias OnCompletion<Failure> = (Failure?) -> Void | |
typealias OnCollect<Output, Failure> = (@escaping OnEach<Output>, @escaping OnCompletion<Failure>) -> shared.Cancellable | |
/** | |
Creates a `Publisher` that collects output from a flow wrapper function emitting values from an underlying | |
instance of `Flow<T>`. | |
*/ | |
func collect<Output, Failure>(_ onCollect: @escaping OnCollect<Output, Failure>) -> Publishers.Flow<Output, Failure> { | |
return Publishers.Flow(onCollect: onCollect) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It will be great if you could provide a sample usage of the above functions in swift.