Skip to content

Instantly share code, notes, and snippets.

@Nillerr
Created May 20, 2021 19:52
Show Gist options
  • Save Nillerr/54f644ee165f22ee79ba8fa730b8f163 to your computer and use it in GitHub Desktop.
Save Nillerr/54f644ee165f22ee79ba8fa730b8f163 to your computer and use it in GitHub Desktop.
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)
}
@abhimuktheeswarar
Copy link

It will be great if you could provide a sample usage of the above functions in swift.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment