Last active
March 3, 2017 02:09
-
-
Save littlebobert/37d68ea540e86c2f4ed8c25d0ff13601 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// before the change | |
BAPromise *promise = [self methodThatReturnsAPromise]; | |
[promise then:^id(id obj) { | |
NSLog(@"1st"); | |
return [[self otherMethodThatReturnsAPromise] then:^id(id obj) { | |
NSLog(@"2nd"); | |
return obj; | |
}]; | |
}]; | |
[promise done:^(id obj) { | |
NSLog(@"3rd"); | |
}]; | |
// after the change | |
BAPromise *promise = [self methodThatReturnsAPromise]; | |
[promise then:^id(id obj) { | |
NSLog(@"1st"); | |
return obj; | |
}]; | |
[promise then:^id(id obj) { | |
NSLog(@"2nd"); | |
return [[self otherMethodThatReturnsAPromise] then:^id(id obj) { | |
NSLog(@"4th"); | |
return obj; | |
}]; | |
}]; | |
[promise done:^(id obj) { | |
NSLog(@"3rd"); | |
}]; | |
// fix | |
BAPromise *promise = [self methodThatReturnsAPromise]; | |
[promise then:^id(id obj) { | |
NSLog(@"1st"); | |
return obj; | |
}]; | |
[promise then:^id(id obj) { | |
NSLog(@"2nd"); | |
BAPromise *promise2 = [[self otherMethodThatReturnsAPromise] then:^id(id obj) { | |
NSLog(@"3rd"); | |
return obj; | |
}]; | |
[promise2 done:^(id obj) { | |
NSLog(@"4th"); | |
}]; | |
return promise2; | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment