Commit Graph

31 Commits

Author SHA1 Message Date
Max Howell
4ff9962082 SKError still is not a real Error, hard-code these
Not ideal, but there’s also no harm in it.
2018-10-02 17:08:38 -04:00
Max Howell
b96bb7be4b Add firstValue(where:) 2018-06-17 14:10:51 -04:00
Max Howell
52c1d2e26d Complete documentation 2018-05-04 22:25:34 -04:00
Max Howell
5875f8f5a3 @available(deprecated: x.y) is for Swift x.y
Not our library version. Which makes no sense at all of course, so thanks for that Swift-core.
2018-02-19 17:12:29 -05:00
Max Howell
d2f37908a3 Provide specific error for this condition 2018-02-19 10:26:32 -05:00
Max Howell
5cd9fd05a0
Rename functional functions; Refs #773
Rename functional functions; Refs #773

See the discussion in #773 and #782 for details.

| Form | Currently | Proposed |
|-------------------------------------------|---------|------------|
| `Promise<T> => ((T) -> U?) => Promise<U>` | flatMap | compactMap |
| `Promise<[T]> => ((T) -> U) => Promise<[U]>` | map | mapValues |
| `Promise<[T]> => ((T) -> [U]) => Promise<[U]>)` | flatMap | flatMapValues |
| `Promise<[T]> => ((T) => U?)` | compactMap | compactMapValues |
| `Promise<[T]> => ((T) -> Promise<U>) => Promise<[U]>` | thenMap | *unchanged* |
| `Promise<[T]> => ((T) -> Promise<[U]>) => Promise<[U]>` | thenFlatMap | *unchanged* |
| `Promise<[T]> => ((T) -> Bool) => Promise<[T]>` | filter | filterValues |
| `Promise<[T]> => Promise<T>` | last | lastValue |
2018-02-19 10:24:59 -05:00
Max Howell
cd150744ed Catch directly; avoid as NSError which can crash 2018-01-16 13:20:47 -05:00
Max Howell
ca17677756 Provide localizedDescription for our errors
Commit minor changes to Social and OMG extensions.
2017-12-04 10:52:28 -05:00
Max Howell
47367f1df6 5.0.0 2017-11-06 09:27:11 -05:00
rikner
0819a2a77d compile for Android 2017-10-13 15:37:26 +02:00
Nolan Waite
46a1ac3380 Add NSUserCancelledError to cancelled error identifiers 2017-07-06 17:24:12 -03:00
Zach Langley
c3be8eb7ef Update NSURL in docs (#656) 2017-05-17 15:35:01 -04:00
Max Howell
fd8124a6d6 Silence Swift 3.1-beta warning
Tag 4.1.7
2017-01-31 22:39:52 -05:00
Max Howell
661c17aff6 Custom PMKURLError description 2016-12-23 10:54:44 +01:00
Carl Brown
175bf5404b Changes to compile on Linux 2016-11-30 15:17:19 -06:00
Zach Langley
bbe0422358 Document all public methods
(At least according to the docs/undocmented.json file created by jazzy.)

Also attemps to unify the documentation style, fixes typos found in
documentation, and adds some functional tests for PMKJoint.
2016-10-28 01:11:24 -07:00
Max Howell
3c3e399545 Rename URLError; Fixes #565 2016-10-18 19:46:22 -04:00
Max Howell
513a504210 SwiftPM support 2016-09-07 15:45:21 -07:00
Max Howell
f4cda6720f - Error.when; + when(resolved/fulfilled:)
Refs #341
2016-09-07 15:45:21 -07:00
Max Howell
67bc256992 PromiseKit 4 / Swift 3 / Xcode 8
http://promisekit.org/news/2016/09/PromiseKit-4.0-Released/
2016-09-07 15:45:21 -07:00
Max Howell
b064b62773 Error if concurrency is <= 0 2016-07-23 13:29:57 -07:00
Oto Kominak
ddbacdf56c Downcasting AnyPromise to Promise<T> using .toPromise(T) (#389) 2016-07-22 22:11:14 -07:00
Leo Mehlig
9bcccaecdd Update to Swift 2.2
Update all code to work with Xcode 7.3
2016-03-22 20:22:58 +01:00
Jacob Wallstrom
ab1bfcdf54 NSError. cancelledError() needs to be public for Swift 2016-01-14 21:28:26 +01:00
Max Howell
af107056ac Disambiguify category promise() functions
Having to specialize your thens makes using PromiseKit much less pleasant.
However naming our functions more verbosely, for example:

    CLLocationManager.promiseLocations()

    // versus

    CLLocationManager.promiseLocation()

Read confusingly. This new idea allows promises to be non-ambiguous yet
specialization is easy. For example:

    NSURLSession.GET(url).then { data in }  // no compiler ambiguity!

    // or:

    NSURLSession.GET(url).asImage().then { image in }
2015-08-12 21:56:42 -07:00
Max Howell
97996d72e7 Fixes to Promises A+ tests 2015-08-12 21:21:24 -07:00
Max Howell
205e2470f9 Warn if cancelled called on bg thread 2015-08-12 21:20:55 -07:00
Max Howell
af27599281 Pass through AnyPromise’s ErrorToken 2015-08-12 21:20:55 -07:00
Max Howell
9962e330c6 Swift join()
Behaves differently to the ObjC one, but this is the way the ObjC one should behave. This way error-handling propagates correctly.
2015-08-12 21:20:54 -07:00
Max Howell
9fd0bdbc65 CancellableErrorType protocol
Swift sources can specify errors to be Cancellable using this more elegant protocol system.

registerCancel… still exists as not all NSErrors can be represented as ErrorTypes directly.

Swift no longer has access to NSError.cancelledError() and does not have an ErrorType replacement. If you are writing Swift it is trivial to make your own custom CancellableErrorType and this is the “Swift-Way”.
2015-08-12 21:20:54 -07:00
Max Howell
2a7df11708 Swift 2: Revised error system (due to ErrorType)
Since ErrorType is not (necessarily) an NSObject we needed to handle the unhandled tokens differently.

Instead we keep an ErrorConsumptionToken with the ErrorType and ensure we pass it around with subsequent promises.

This appears to work for all possible Swift paths and thus I think it will work for all ObjC paths too and it may be worth switching to this system.

The reason the other system was used (add a runtime iVar) is so that errors that are consumed but then end up going back into the a chain are known to already be consumed. However with further realization it is apparent that any error that goes back into a chain is unconsumed and thus the new system should be work well in all cases.
2015-08-12 21:20:53 -07:00