Reactivecocoa Study notes--usage

Source: Internet
Author: User

1. Monitor changes in UI variables

Return and pass the value down.

1.1. Output

[Self.usernameTextField.rac_textSignal subscribenext:^ (ID x) {  NSLog (@ "%@", x);}];

1.2, filter, output

[[Self.usernameTextField.rac_textSignal  Filter:^bool (nsstring*text) {    return text.length > 3;  }]  subscribenext:^ (id x) {    NSLog (@ "%@", x);  }];

1.3, change the data type, filter-and output

[[[Self.usernameTextField.rac_textSignal  Map:^id (nsstring*text) {    return @ (text.length);  }]  Filter:^bool (nsnumber*length) {    return[length integervalue] > 3;  }]  subscribenext:^ (id x) {    NSLog (@ "%@", x);  }];

1.4. Another way to Subscribenext

The RAC macro allows the output of the signal to be applied directly to the properties of the object. The RAC macro has two parameters, the first is the object that needs to set the property value, and the second is the property name. Each time a signal generates a next event, the passed value is applied to the attribute.

RAC (Self.passwordtextfield, backgroundcolor) =  [validpasswordsignal    map:^id (NSNumber *passwordvalid) {      return[passwordvalid Boolvalue]? [Uicolor Clearcolor]:[uicolor Yellowcolor];    }];

Reactivecocoa Study notes--usage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.