Created
December 10, 2015 11:07
-
-
Save saiday/27a049e10f0961b15358 to your computer and use it in GitHub Desktop.
PromiseKit callback chaining
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
| // Method signatures | |
| // Promise resolves to User instance | |
| - (PMKPromise *)loginToRemoteServer:(NSString *)userId; | |
| // Promise resolves to NSDictionary of user data | |
| - (PMKPromise *)retrieveUserData:(User *)user; | |
| // Promise resolves to UIImage | |
| - (PMKPromise *)retrieveProfileImage:(NSURL *)imageURL; | |
| [self loginToRemoteServer:userId].then(^(User *user) { | |
| self.user = user; | |
| [self retrieveUserData:user].then(^(NSDictionary *userData){ | |
| self.user.data = userData; | |
| [self retrieveProfileImage:userData.profileImageURL].then(^(UIIMage *userImage){ | |
| self.user.profileImage = userImage; | |
| }); | |
| }); | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment