You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
590 B

  1. //
  2. // Promise+NoMatterWhat.swift
  3. // then
  4. //
  5. // Created by Sacha Durand Saint Omer on 24/02/2017.
  6. // Copyright © 2017 s4cha. All rights reserved.
  7. //
  8. import Foundation
  9. extension Promise {
  10. public func noMatterWhat(_ block: @escaping () -> Void) -> Promise<T> {
  11. let p = newLinkedPromise()
  12. syncStateWithCallBacks(
  13. success: { t in
  14. block()
  15. p.fulfill(t)
  16. },
  17. failure: { e in
  18. block()
  19. p.reject(e)
  20. },
  21. progress: p.setProgress)
  22. return p
  23. }
  24. }