reactive-cocoa

How-to combine AFNetworking 2.0 with reactive cocoa to chain a queue of requests together?

不打扰是莪最后的温柔 提交于 2019-12-12 10:18:11
问题 I have several Requests that depend on each other and must me called in sequence? Can somebody give me an example using AFNetworking and reactive cocoa? Example: LoginRequest (return transactionId) UpdateRequest post data with transactionId UploadRequest jpeg with transactionId EndRequest with transactionId 回答1: The method names are clearly made-up but should give you a sense of the form of the code you'd write: [[self executeLoginRequest] flattenMap:^(id transactionId) { return [[[self

Can/How Should I replace my KVO stuff with RC3?

Deadly 提交于 2019-12-12 07:35:54
问题 I'm trying to port an objc app which uses Facebook's KVOController, to Swift. I've been encouraged to look at RC3 as an alternate and more Swiftish approach. I've read some blogs and I'm encouraged to give this a try. But much of the docs and blogs seem to concentrate on sockets and timers as examples. So I have two simple questions right now: 1) Given an objc fragment like: [self.KVOController observe: self.site keyPath: @"programs" options: NSKeyValueObservingOptionInitial block:^(id

Looking for the most elegant way to chain a dependent tree of network requests with reactive cocoa?

纵然是瞬间 提交于 2019-12-12 05:09:13
问题 This is the solution from my last question: Since I am new to reactiveCocoa I am a little unsure if this is the right way to go? Basicly I want to get my dependent network Requests sent serialized one after the other. They form a tree so the parent is sent first and then any children and then the next parent: After doing some testing the underneath code seems to do exactly what I want: Could somebody tell me if I am using reactiveCocoa the right way? Could I run into deadlocks? #import

Authenticating with ReactiveCocoa

萝らか妹 提交于 2019-12-12 02:07:35
问题 I'm building an app on top of ReactiveCocoa and Octokit.objC (github library). As part of my effort I'm using Octokits ReactiveCocoa signals to access resources that require authentication. A previous question 'Retrying an asynchronous operation using ReactiveCocoa' does a nice job covering the case where the user wants to 'retry an asynchronous operation' once . I'm trying to figure out how to handle the case where you might want to retry several times. In my specific case if authentication

DataSource methods with RACSignals

好久不见. 提交于 2019-12-12 01:44:18
问题 Can I implement dataSource method with RACSignal that returns value. I wan't something like this - [self rac_signalForSelector:@selector(tableView:numberOfRowsInSection:)]{ return @10;}]; How to deal with methods that needs a return values when you work with signal? 回答1: ReactiveCocoa, like all Reactive Extensions-based frameworks, is designed around a push-based API for operating on a series of values. That is, you have some source of values and then you use signal composition to react to

Cancel RACCommand execution

a 夏天 提交于 2019-12-11 10:58:10
问题 Is there any way to cancel execution of a RACCommand ? For example I have a command with infinite execution signal like this: RACCommand *command = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input) { return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) { __block BOOL stop = NO; while (!stop) { [subscriber sendNext:nil]; } return [RACDisposable disposableWithBlock:^{ stop = YES; }]; }]; }]; So how can I stop it after calling [command execute:nil] ? 回答1: I

ReactiveCocoa takeUntil 2 possible signals?

南笙酒味 提交于 2019-12-11 10:55:13
问题 So I have successfully turned a button into an off and on switch that changes the label. I was also able to have it start a timed processed set off when that is to occur, and it have the ability to shut off the timed process. Anyways I need to way to shut down the timed process I was wondering if there was a way to stop it without using the disposable. With a second takeUntil signal. Edit I think what I was trying to do was slightly misleading let me show my current solution that works. -

Use of unresolved operator '<~'

社会主义新天地 提交于 2019-12-11 04:56:47
问题 I am using ReactiveCocoa 5.0 alpha 3, ReactiveSwift and Swift 3 I am having issues with binding my UITextField to a MutableProperty. In ReactiveCocoa 4, I used this:- extension UITextField { func signalProducer() -> SignalProducer<String, NoError> { return self.rac_textSignal().toSignalProducer() .map { $0 as! String } .flatMapError { _ in return SignalProducer<String, NoError>.empty } } } viewModel.email <~ emailTextField.signalProducer() But now in ReactiveCocoa 5, I am not able to do that.

How do I observe a signal and immediately receive a `next` event if it has already occured?

风格不统一 提交于 2019-12-10 22:57:22
问题 I'm trying to wrap an API call that initializes an object after a network request. I don't want the network request to happen for every new observer, so as I understand it, I shouldn't be using SignalProducer . However, by using a single Signal , only the first usage of it will receive a next event, while any newer subscribers will never receive the current value. How should I be doing this? I'm probably doing something fundamentally wrong with RAC. extension SparkDevice { static func

Observe every item in RACSequence

纵饮孤独 提交于 2019-12-10 22:16:12
问题 I have a method on ParentViewModel which returns an RACSequence of ViewModel objects like so: - (RACSequence *) viewModels { return [self.models.rac_sequence map:^id(Model *model) { return [[ViewModel alloc] initWithModel: model]; }]; } Each of the ViewModels has a state property on which is an enum and has 3 states: NotStarted, InProgress and Completed. When all the ViewModels in my sequence have the state Completed I know ParentViewModel is valid. I have a validSignal on the ParentViewModel