Last active
December 15, 2015 15:39
-
-
Save simonpang/5283706 to your computer and use it in GitHub Desktop.
Dreaming of promise base API for event handling
This file contains 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
- (id)init | |
{ | |
if (self = [super initNibName:nil bundle:nil]) { | |
[[self whenViewDidLoad] then:^{ | |
id loginPromise = [client login:self.loginField password:self.passwordField when:[self.loginButton whenTouchDown]]; | |
[UIAlertView presentMessage:^{ return [loginPromise alertError]; } when:[loginPromise whenFail]]; | |
[client saveAccessToken:[self.loginPromise whenSuccess]]; | |
[self presentModalViewController:[RegisterViewController willCreate] when:[self.registerButton whenTouchDown]]; | |
}]; | |
} | |
return self; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment