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.

21 lines
475 B

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