Async library inspired by CommonJS Promises/A spec
http://wiki.commonjs.org/wiki/Promises/A
KSDeferred *deferred = [KSDeferred defer];
return deferred.promise;
[promise then:^id(id value) {
.. do something ..
return value;
} error:^id(NSError *e) {
.. handle error ..
return e;
}];
KSPromise *chained = [promise then:^id(id value) {
return value;
} error:^id(NSError *e) {
return e;
}];
[chained then:^id(id value) {
# value is value returned from first promise
} error:^id(NSError *e) {
# error is error returned from first promise
}];
[deferred resolveWithValue:@"VALUE"];
NSError *someError;
[deferred rejectWithError:someError];
- Kurtis Seebaldt, Pivotal Labs
Copyright (c) 2013 Kurtis Seebaldt. This software is licensed under the MIT License.