Skip to content

Instantly share code, notes, and snippets.

@simonpang
Last active December 15, 2015 15:39
Show Gist options
  • Save simonpang/5283706 to your computer and use it in GitHub Desktop.
Save simonpang/5283706 to your computer and use it in GitHub Desktop.
Dreaming of promise base API for event handling
- (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