-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
'Cancel' for PromiseKit -- provides the ability to cancel promises an…
…d promise chains
- Loading branch information
1 parent
41bab77
commit ff69f82
Showing
8 changed files
with
150 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
github "mxcl/PromiseKit" ~> 6.0 | ||
#github "mxcl/PromiseKit" ~> 6.0 | ||
github "dougzilla32/PromiseKit" "CoreCancel" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
github "mxcl/PromiseKit" "6.3.3" | ||
github "dougzilla32/PromiseKit" "ff694600d4d03458121515bdc027ba76df14f7ef" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import PromiseKit | ||
import PMKUIKit | ||
import XCTest | ||
import UIKit | ||
|
||
@available(iOS 10, tvOS 10, *) | ||
class UIViewPropertyAnimatorTests: XCTestCase { | ||
func test() { | ||
let ex1 = expectation(description: "") | ||
let ex2 = expectation(description: "") | ||
|
||
let animator = UIViewPropertyAnimator(duration: 0.1, curve: .easeIn, animations: { [weak self] in | ||
ex1.fulfill() | ||
}) | ||
animator.startAnimation(.promise).done { _ in | ||
ex2.fulfill() | ||
} | ||
|
||
waitForExpectations(timeout: 1) | ||
} | ||
} | ||
|
||
//////////////////////////////////////////////////////////// Cancellation | ||
|
||
@available(iOS 10, tvOS 10, *) | ||
extension UIViewPropertyAnimatorTests { | ||
func testCancel() { | ||
let ex1 = expectation(description: "") | ||
let ex2 = expectation(description: "") | ||
|
||
let animator = UIViewPropertyAnimator(duration: 0.1, curve: .easeIn, animations: { [weak self] in | ||
ex1.fulfill() | ||
}) | ||
let p = animator.cancellableStartAnimation(.promise).done { _ in | ||
XCTFail() | ||
}.catch(policy: .allErrors) { error in | ||
error.isCancelled ? ex2.fulfill() : XCTFail("Error: \(error)") | ||
} | ||
p.cancel() | ||
|
||
XCTAssert(animator.isCancelled) | ||
XCTAssert(p.isCancelled) | ||
|
||
waitForExpectations(timeout: 1) | ||
} | ||
} |