Skip to content

Instantly share code, notes, and snippets.

@SunXiaoShan
Last active July 7, 2017 08:26
Show Gist options
  • Save SunXiaoShan/d51a3d13bcc4569e56ed06b665c9d327 to your computer and use it in GitHub Desktop.
Save SunXiaoShan/d51a3d13bcc4569e56ed06b665c9d327 to your computer and use it in GitHub Desktop.
UIView on ReactiveObjC
// 監聽 UITextField 當內文有改變的時候,會執行內部 function
[[self.textView rac_signalForControlEvents:UIControlEventEditingChanged] subscribeNext:^(__kindof UIControl * _Nullable x) {
NSLog(@"text change");
}];
// 監聽 button UIControlEventTouchUpInside 狀態
[[self.btnButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
NSLog(@"button click");
}];
// 3秒後,執行 block 裡面程式碼
[[RACScheduler mainThreadScheduler] afterDelay:3 schedule:^{
NSLog(@"execute after 3 sec");
}];
// 每 2秒,執行 block 裡面程式碼
[[RACSignal interval:2 onScheduler:[RACScheduler mainThreadScheduler]] subscribeNext:^(id x) {
NSLog(@"execute per 2 sec");
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment