Skip to content

Instantly share code, notes, and snippets.

@binho
Last active August 29, 2015 14:00
Show Gist options
  • Save binho/11276318 to your computer and use it in GitHub Desktop.
Save binho/11276318 to your computer and use it in GitHub Desktop.
RAC Examples
// Check form
RACSignal *formValidate = [RACSignal
combineLatest:@[self.textField.rac_textSignal]
reduce:^(NSString *email) {
NSRange at = [email rangeOfString:@"@"];
return @(at.location != NSNotFound);
}];
[[formValidate map:^id(NSNumber *isValid) {
return isValid;
}]
subscribeNext:^(NSNumber *isValid) {
if ([isValid boolValue]) {
self.textLabel.backgroundColor = [UIColor greenColor];
self.textLabel.text = @"EMAIL VALIDO!";
} else {
self.textLabel.backgroundColor = [UIColor redColor];
self.textLabel.text = @"EMAIL INVALIDO!";
}
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment