Skip to content

Instantly share code, notes, and snippets.

@nukedbit
Last active February 21, 2021 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nukedbit/0fd65fb1fb9845cf26496287e9c4bf6d to your computer and use it in GitHub Desktop.
Save nukedbit/0fd65fb1fb9845cf26496287e9c4bf6d to your computer and use it in GitHub Desktop.
PromiseKit Extension for Combine
// Example at https://nukedbit.dev/a-simple-extension-to-use-combine-with-promisekit/
extension Promise {
var publisher : AnyPublisher<T, Error> {
Future<T, Error> {
promise in
self.done {
body in
promise(.success(body))
}.catch {
error in
promise(.failure(error))
}
}.eraseToAnyPublisher()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment