reactive-cocoa

Enabling an UIButton using Reactive Cocoa RACSignal

南楼画角 提交于 2019-12-05 02:48:38
问题 I have a UIButton added to a view. My view also has three text box viz. username , password and confirmPassword . Based on the legitimate content of these text box, I need to enable my signUp button. Here is my code snippet :- UIButton *signUp = [[UIButton alloc]initWithFrame:CGRectMake(10, 100, 50, 20)]; signUp.backgroundColor = [UIColor greenColor]; signUp.enabled = NO ; [self.view addSubview:signUp]; RACSignal *formValid = [RACSignal combineLatest:@[ username.rac_textSignal, password.rac

How to install ReactiveCocoa properly using CocoaPods?

China☆狼群 提交于 2019-12-04 14:03:17
I'm very new to ReactiveCocoa . I tried to install ReactiveCocoa a couple of days ago via CocoaPods . Here is my podFile : platform :ios , '7.0' pod 'ReactiveCocoa' After using pod install I have the log file here: Analyzing dependencies Downloading dependencies Using ReactiveCocoa (2.0) Generating Pods project Integrating client project And then I open myproject.xworkspace and #import <ReactiveCocoa.h> to start using the framework. But the problem is I cannot get it worked For example in my code I have this line: objc RACSignal *usernameSignal = self._usernameTextField.rac_textSignal; But

Meaning of Objective-C macros prefixed with an at (@) symbol

為{幸葍}努か 提交于 2019-12-04 08:23:20
问题 The ReactiveCocoa framework makes use of weakify and strongify macros, both of which are preceded by an '@' symbol. Here's an example (From this file). - (RACSignal *)rac_textSignal { @weakify(self); return [[[[RACSignal ... ]; } What is the significance of the at symbol that is a prefix to the macro name? (NOTE: I have checked the macro, and it is called 'weakify', not '@weakify', so it isn't just the macro name!). The macro itself is defined here: https://github.com/jspahrsummers/libextobjc

What is the reason of @strongify

烂漫一生 提交于 2019-12-04 06:58:43
In ReactiveCocoa there is macro to prevent retain cycle @weakify and @strongify. From my understanding @weakify do something like what I usually do that is create __weak reference for using in the block, but what about @strongify ? Why do I need to make it strong again in the block? Here is some sample usage: @weakify(self); [RACObserve(self, username) subscribeNext:^(NSString *username) { @strongify(self); [self validateUsername]; }]; If you just use a weak reference within the block, self can get deallocated while the block is being executed. But if you want to ensure that self stays in

Understanding ReactiveCocoa and MVVM in my ReactiveCocoa test project

久未见 提交于 2019-12-04 06:54:58
I've written a very simple ReactiveCocoa test application to try my hand at coding in RAC (rather than just reading about it endlessly). It's on Github , and I wanted to get some specific questions about it answered. I'll link to the code components as I go along. First, a brief explanation of the application: it's a timer-driven iteration counter that can be paused by the user. (Its purpose is to count how many seconds have elapsed, eliding the ones where the user paused it.) Once a second, a timer increments a variable iff the user hasn't paused the incrementing behaviour. There are three

ReactiveCocoa combine SignalProducers into one

对着背影说爱祢 提交于 2019-12-04 06:20:59
I'm using ReactiveCocoa and I have several SignalProducers let center = NSNotificationCenter.defaultCenter() let signalProducer1 = center.rac_notification(name: notificationName1, object: nil) let signalProducer2 = center.rac_notification(name: notificationName2, object: nil) let signalProducer3 = center.rac_notification(name: notificationName3, object: nil) I want to combine them into a single signal producer that produces a signal whenever one of them produces a signal. At first the combineLatest function looked like a good solution let combinedProducer = combineLatest(signalProducer1,

Unit-testing a simple usage of RACSignal with RACSubject

给你一囗甜甜゛ 提交于 2019-12-03 21:51:32
(I may be using this in a totally incorrect manner, so feel free to challenge the premise of this post.) I have a small RACTest app ( sound familiar? ) that I'm trying to unit test. I'd like to test MPSTicker , one of the most ReactiveCocoa-based components. It has a signal that sends a value once per second that accumulates, iff an accumulation flag is set to YES. I added an initializer to take a custom signal for its incrementing signal, rather than being only timer-based. I wanted to unit test a couple of behaviours of MPSTicker: Verify that its accumulation signal increments properly (i.e.

Retrying an asynchronous operation using ReactiveCocoa

孤人 提交于 2019-12-03 19:32:57
问题 I'm using ReactiveCocoa signals to represent calls to RESTful backend in our system. Each RESTful invocation should receive a token as one of the parameters. The token itself is received from authentication API call. All works fine and we're now introduced token expiration, so the backend access class may need to reauthorize itself if the API call fails with HTTP code 403. I want to make this operation completely transparent for the callers, this is the best I came up with: - (RACSignal *

Enabling an UIButton using Reactive Cocoa RACSignal

跟風遠走 提交于 2019-12-03 19:07:13
I have a UIButton added to a view. My view also has three text box viz. username , password and confirmPassword . Based on the legitimate content of these text box, I need to enable my signUp button. Here is my code snippet :- UIButton *signUp = [[UIButton alloc]initWithFrame:CGRectMake(10, 100, 50, 20)]; signUp.backgroundColor = [UIColor greenColor]; signUp.enabled = NO ; [self.view addSubview:signUp]; RACSignal *formValid = [RACSignal combineLatest:@[ username.rac_textSignal, password.rac_textSignal, confirmPassword.rac_textSignal ] reduce:^(NSString *username, NSString *password, NSString

ReactiveSwift Simple Example

北城余情 提交于 2019-12-03 17:11:42
问题 I've read the documentation, gone through their wonderful Playground example, searched S.O., and reached the extent of my google-fu, but I cannot for the life of me wrap my head around how to use ReactiveSwift. Given the following.... class SomeModel { var mapType: MKMapType = .standard var selectedAnnotation: MKAnnotation? var annotations = [MKAnnotation]() var enableRouteButton = false // The rest of the implementation... } class SomeViewController: UIViewController { let model: SomeModel