Skip to content

Commit

Permalink
fix type name
Browse files Browse the repository at this point in the history
  • Loading branch information
NianJi committed Mar 11, 2019
1 parent 302c442 commit 009f30e
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ - (NSString*)cachePathForFileName:(NSString*)name{
}

- (COPromise*)_getDataWithURL:(NSString*)url{
return [COPromise promise:^(COPromiseFullfill _Nonnull resolve, COPromiseReject _Nonnull reject) {
return [COPromise promise:^(COPromiseFulfill _Nonnull resolve, COPromiseReject _Nonnull reject) {
[NSURLSession sharedSession].configuration.requestCachePolicy = NSURLRequestReloadIgnoringCacheData;
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:[NSURL URLWithString:url] completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ @interface coobjcAutoreleaseArcTests : XCTestCase
@implementation coobjcAutoreleaseArcTests

- (COPromise<NSNumber*>*)makeAsynPromise{
return [COPromise promise:^(COPromiseFullfill resolve, COPromiseReject reject) {
return [COPromise promise:^(COPromiseFulfill resolve, COPromiseReject reject) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
resolve(@1);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ @interface coobjcAutoreleaseTests : XCTestCase
@implementation coobjcAutoreleaseTests

- (COPromise<NSNumber*>*)makeAsynPromise{
return [COPromise promise:^(COPromiseFullfill _Nonnull resolve, COPromiseReject _Nonnull reject) {
return [COPromise promise:^(COPromiseFulfill _Nonnull resolve, COPromiseReject _Nonnull reject) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
resolve(@1);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,23 @@ static id testPromise2() {
}

static COPromise *testPromise11() {
return [COPromise promise:^(COPromiseFullfill _Nonnull fullfill, COPromiseReject _Nonnull reject) {
return [COPromise promise:^(COPromiseFulfill _Nonnull fullfill, COPromiseReject _Nonnull reject) {

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
fullfill(@"1");
});
}];
}
static COPromise *testPromise12() {
return [COPromise promise:^(COPromiseFullfill _Nonnull fullfill, COPromiseReject _Nonnull reject) {
return [COPromise promise:^(COPromiseFulfill _Nonnull fullfill, COPromiseReject _Nonnull reject) {

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
fullfill(@"2");
});
}];
}
static COPromise *testPromise13() {
return [COPromise promise:^(COPromiseFullfill _Nonnull fullfill, COPromiseReject _Nonnull reject) {
return [COPromise promise:^(COPromiseFulfill _Nonnull fullfill, COPromiseReject _Nonnull reject) {

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
reject([NSError errorWithDomain:@"aa" code:3 userInfo:@{}]);
Expand All @@ -82,7 +82,7 @@ static id testPromise2() {
}

static COPromise *testPromise21() {
return [COPromise promise:^(COPromiseFullfill _Nonnull fullfill, COPromiseReject _Nonnull reject) {
return [COPromise promise:^(COPromiseFulfill _Nonnull fullfill, COPromiseReject _Nonnull reject) {

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
fullfill(@"1");
Expand All @@ -91,7 +91,7 @@ static id testPromise2() {
}

static COPromise *testPromise22() {
return [COPromise promise:^(COPromiseFullfill _Nonnull fullfill, COPromiseReject _Nonnull reject) {
return [COPromise promise:^(COPromiseFulfill _Nonnull fullfill, COPromiseReject _Nonnull reject) {

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
fullfill(@"2");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

static COPromise<NSData *> *co_downloadWithURL(NSString *url) {

return [COPromise promise:^(COPromiseFullfill _Nonnull fullfill, COPromiseReject _Nonnull reject) {
return [COPromise promise:^(COPromiseFulfill _Nonnull fullfill, COPromiseReject _Nonnull reject) {

[NSURLSession sharedSession].configuration.requestCachePolicy = NSURLRequestReloadIgnoringCacheData;
NSURLSessionDownloadTask *task = [[NSURLSession sharedSession] downloadTaskWithURL:[NSURL URLWithString:url] completionHandler:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ - (void)dealloc{

COPromise<COTuple*>*
cotest_downloadJSONWithURL(NSString *url){
return [COPromise promise:^(COPromiseFullfill _Nonnull resolve, COPromiseReject _Nonnull reject) {
return [COPromise promise:^(COPromiseFulfill _Nonnull resolve, COPromiseReject _Nonnull reject) {
NSURLSessionTask *task = [[NSURLSession sharedSession] dataTaskWithURL:[NSURL URLWithString:url] completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response;
if (!error && httpResponse.statusCode != 404) {
Expand All @@ -65,7 +65,7 @@ - (void)dealloc{

COPromise<COTuple*>*
cotest_loadContentFromFile(NSString *filePath){
return [COPromise promise:^(COPromiseFullfill _Nonnull resolve, COPromiseReject _Nonnull reject) {
return [COPromise promise:^(COPromiseFulfill _Nonnull resolve, COPromiseReject _Nonnull reject) {
if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
NSData *data = [[NSData alloc] initWithContentsOfFile:filePath];
resolve(co_tuple(filePath, data, nil));
Expand Down
4 changes: 2 additions & 2 deletions coobjc/promise/COPromise.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ typedef void (^COPromiseOnCancelBlock)(COPromise *promise);
/**
Define the resolve prototype
*/
typedef void (^COPromiseFullfill)(id _Nullable );
typedef void (^COPromiseFulfill)(id _Nullable );

/**
Define the reject prototype
Expand All @@ -58,7 +58,7 @@ typedef void (^COPromiseReject)(NSError *);
/**
Define the constructor's prototype
*/
typedef void (^COPromiseConstructor)(COPromiseFullfill fullfill, COPromiseReject reject);
typedef void (^COPromiseConstructor)(COPromiseFulfill fullfill, COPromiseReject reject);

/**
Tell the promise is pending or not.
Expand Down
6 changes: 3 additions & 3 deletions coobjc/promise/COPromise.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@ - (instancetype)initWithContructor:(COPromiseConstructor)constructor queue:(disp
self = [self init];
if (self) {
if (constructor) {
COPromiseFullfill fullfill = ^(id value){
COPromiseFulfill fulfill = ^(id value){
[self fulfill:value];
};
COPromiseReject reject = ^(NSError *error){
[self reject:error];
};
if (queue) {
dispatch_async(queue, ^{
constructor(fullfill, reject);
constructor(fulfill, reject);
});
} else {
constructor(fullfill, reject);
constructor(fulfill, reject);
}
}
}
Expand Down

0 comments on commit 009f30e

Please sign in to comment.