reactive-cocoa

Why doesn't SignalProducer return a Signal?

天涯浪子 提交于 2019-12-07 01:09:22
问题 I feel like I understand all of the basic components of ReactiveCocoa (conceptually), by understanding how to connect all of the pieces together is still a bit confusing. For example, after reading about Signal, I fully expected SignalProducer to just have one start() method which returned a Signal, which you would use like so: mySignalProducer.start().observe(myObserver) Instead, you have to pass an observer into start(), and SignalProducer calls observe() for you: mySignalProducer.start

Reactive Cocoa - UITextView's rac_textSignal doesn't get called when programmatically setting text

匆匆过客 提交于 2019-12-07 00:16:58
问题 I'm implementing a chat UI, and using Reactive Cocoa to adjust the chat bubble's size as the user types. Currently, I'm updating the UI's layout based on the textview's rac_textSignal . Everything's working great - except for one bit: when the user sends the message, I programmatically clear the textfield: _inputTextView.text = @""; ... but the textview's rac_textSignal doesn't activate. I hear this is a feature with ReactiveCocoa - but what's the proper way to build this? Do I need to have

UITextField get focus and then lose focus immediately due to return YES in textFieldShouldReturn

泪湿孤枕 提交于 2019-12-06 15:43:53
Here are my codes: - (void)viewDidLoad { [super viewDidLoad]; // passwordTextField cannot get focus after click next key due to this RAC RAC(self.loginButton, enabled) = [RACSignal combineLatest:@[self.userTextField.rac_textSignal, self.passwordTextField.rac_textSignal] reduce:^id (NSString *user, NSString *password) { if ([user length] > 0 && [password length] > 0) { return @YES; } return @NO; }]; } - (BOOL)textFieldShouldReturn:(UITextField *)textField { if (textField == self.userTextField) { [self.passwordTextField becomeFirstResponder]; } else { [self loginAction:textField]; } //

How to install ReactiveCocoa properly using CocoaPods?

有些话、适合烂在心里 提交于 2019-12-06 07:46:56
问题 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

What is the reason of @strongify

廉价感情. 提交于 2019-12-06 02:23:38
问题 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]; }]; 回答1: If you just use a weak reference within the block,

Understanding ReactiveCocoa and MVVM in my ReactiveCocoa test project

最后都变了- 提交于 2019-12-06 01:27:34
问题 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

How to obtain a UIAlertController observable (ReactiveCocoa or RxSwift)?

房东的猫 提交于 2019-12-06 00:09:11
问题 I implemented a "reactive" UIAlertController so I can get an Observable<Int> of the button press. (See code below). My question, or questions, are: Is this implementation correct? I don't like storing the observers; I wonder if there's a better solution. Or... is there already an implementation of this in ReactiveCocoa or RxSwift? Here is the implementation. I removed the parts not relevant to te question. class AlertBuilder { typealias AlertAction = (Int) -> () private let alert:

Why doesn't SignalProducer return a Signal?

℡╲_俬逩灬. 提交于 2019-12-05 05:44:44
I feel like I understand all of the basic components of ReactiveCocoa (conceptually), by understanding how to connect all of the pieces together is still a bit confusing. For example, after reading about Signal, I fully expected SignalProducer to just have one start() method which returned a Signal, which you would use like so: mySignalProducer.start().observe(myObserver) Instead, you have to pass an observer into start(), and SignalProducer calls observe() for you: mySignalProducer.start(myObserver) This means that the interface of SignalProducer is much larger (more to understand), because

Reactive Cocoa - UITextView's rac_textSignal doesn't get called when programmatically setting text

送分小仙女□ 提交于 2019-12-05 05:19:10
I'm implementing a chat UI, and using Reactive Cocoa to adjust the chat bubble's size as the user types. Currently, I'm updating the UI's layout based on the textview's rac_textSignal . Everything's working great - except for one bit: when the user sends the message, I programmatically clear the textfield: _inputTextView.text = @""; ... but the textview's rac_textSignal doesn't activate. I hear this is a feature with ReactiveCocoa - but what's the proper way to build this? Do I need to have an NSString holding the currentlyTypedString , and drive the UI changes when that string updates? Yep,

Enum case switch not found in type

一个人想着一个人 提交于 2019-12-05 03:22:37
Can someone please help me with this. I have the following public enum public enum OfferViewRow { case Candidates case Expiration case Description case Timing case Money case Payment } And the following mutableProperty: private let rows = MutableProperty<[OfferViewRow]>([OfferViewRow]()) In my init file I use some reactiveCocoa to set my MutableProperty: rows <~ application.producer .map { response in if response?.application.status == .Applied { return [.Candidates, .Description, .Timing, .Money, .Payment] } else { return [.Candidates, .Expiration, .Description, .Timing, .Money, .Payment] } }