reactive-cocoa-3

ReactiveCocoa 4: How to send error to an observer without interrupting the signal

坚强是说给别人听的谎言 提交于 2020-01-04 05:23:50
问题 let (signal, sink) = Signal<[CLBeacon], BeaconManagerError>.pipe() When I call this because the user disabled the Bluetooth: sendError(self.sink, error) the Signal is interrupted and I don't receive more next nor interrupted events after enabling the Bluetooth back again. The Signal is broken. How can I send error types to the observer without interrupting / breaking the Signal ? I can't find in the RAC 4 documentation. Thanks! 回答1: By design, an error causes the signal to finish. The

ReactiveCocoa combine SignalProducers into one

半世苍凉 提交于 2019-12-21 11:57:04
问题 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

ReactiveCocoa combine SignalProducers into one

不羁的心 提交于 2019-12-21 11:56:20
问题 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

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

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

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,

How to implement a basic UITextField input + UIButton action scenario using ReactiveCocoa 3?

岁酱吖の 提交于 2019-12-03 09:49:38
问题 I'm a Swift and ReactiveCocoa noob at the same time. Using MVVM and Reactive Cocoa v3.0-beta.4 framework, I'd like to implement this setup, to learn the basics of the new RAC 3 framework. I have a text field and I want the text input to contain more than 3 letters, for validation. If the text passes the validation, the button underneath should be enabled. When the button receives the touch down event, I want to trigger an action using the view model's property. Since there are very few

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

我是研究僧i 提交于 2019-12-03 08:26:18
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 observer, id object, NSDictionary *change) { [self.tableView reloadData]; }]; What is the simple way to

How to implement a basic UITextField input + UIButton action scenario using ReactiveCocoa 3?

时光毁灭记忆、已成空白 提交于 2019-12-03 01:27:06
I'm a Swift and ReactiveCocoa noob at the same time. Using MVVM and Reactive Cocoa v3.0-beta.4 framework, I'd like to implement this setup, to learn the basics of the new RAC 3 framework. I have a text field and I want the text input to contain more than 3 letters, for validation. If the text passes the validation, the button underneath should be enabled. When the button receives the touch down event, I want to trigger an action using the view model's property. Since there are very few resources about RAC 3.0 beta at the moment, I implemented the following by reading the QAs on the framework's

Simple observable struct with RxSwift?

半世苍凉 提交于 2019-12-01 12:47:14
I'm trying to come up with a simple observable object in Swift and thought to use RxSwift . I couldn't find a simple example to do something like this: protocol PropertyObservable { typealias PropertyType var propertyChanged: Event<(PropertyType, Any)> { get } } class Car: PropertyObservable { typealias PropertyType = CarProperty let propertyChanged = Event<(CarProperty, Any)>() dynamic var miles: Int = 0 { didSet { propertyChanged.raise(.Miles, oldValue as Any) } } dynamic var name: String = "Turbo" { didSet { propertyChanged.raise(.Name, oldValue as Any) } } } The above is pure Swift