Skip to content

Instantly share code, notes, and snippets.

@Amzd
Created December 7, 2020 11:26
Show Gist options
  • Save Amzd/2afac9a329d3fd0ca882d29f7c9adeac to your computer and use it in GitHub Desktop.
Save Amzd/2afac9a329d3fd0ca882d29f7c9adeac to your computer and use it in GitHub Desktop.
Empty and constant AnyPublisher extensions
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
extension AnyPublisher {
static var empty: Self {
Empty(completeImmediately: false).eraseToAnyPublisher()
}
static func constant(_ value: Output) -> Self where Failure == Never {
Just(value).eraseToAnyPublisher()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment