Questions tagged [reactive-swift]

Anything related to the ReactiveSwift library that brings the reactive programming primitives in Swift

ReactiveSwift is a library that brings the reactive programming approach on Swift. It offers composable, declarative, and flexible primitives that are built around the grand concept of streams of values over time.

This is a pure-Swift implementation of the reactive API. It provides all the nuts and bolts, including Signals, SignalProducers, Properties, Actions and Bindings.

ReactiveSwift documentation

ReactiveSwift project on GitHub

124 questions
3
votes
1 answer

Lifetime purpose on ReactiveSwift

I've been using ReactiveSwift for a few months now but there is a something that I dont fully understand: lifetime objects. For example, lets say I have a SignalProducer which will make an API call, this is wrapped on a class: class ServiceWrapped…
rgkobashi
  • 2,551
  • 19
  • 25
3
votes
2 answers

Given a list of timers, how to output if one of them completed, while also being able to reset the list?

I have an output signal that should output when one of a given set of timers time out, complete or when the entire list is reset. enum DeviceActionStatus { case pending case completed case failed } struct DeviceAction { let start:…
bogen
  • 9,954
  • 9
  • 50
  • 89
3
votes
2 answers

Mock a Reactive?

I have a ViewModel which has as an input in its initializer init(sliderEvents: Reactive) { In the test i want to do something like slider.send(.touchDownInside) slider.send(.valueChanged, 5) slider.send(.valueChanged, 15) To simulate for…
bogen
  • 9,954
  • 9
  • 50
  • 89
3
votes
3 answers

Is there a way to make a signal similar to combineLatest without needing all the signals to initially fire?

I have an array of signals var signals = [Signal]() where enum ActionResult case failed case pending case completed } I want to create a combined signal that returns true if one or more of the signals fires a…
bogen
  • 9,954
  • 9
  • 50
  • 89
3
votes
1 answer

Migrate from RACSignal to ReactiveSwift or RAC5

I'm new with Swift, and that's why I'm new with Reactive Cocoa v5 or Reactive Swift. Previously I used RACSignal with RAC 2.x and I liked to do something like this: - (RACSignal *)signalForGET:(NSString *)URLString parameters:(NSDictionary…
Stas Ivanov
  • 917
  • 1
  • 10
  • 22
3
votes
1 answer

Simple code swift to reactiveswift

People how I can convert my code: struct CarModel { var model: String? var make: String? var kilowatts: Int? var photoURL: String? init(model: String, make: String, kilowatts: Int, photoURL: String) { self.model = model …
Vladyslav
  • 33
  • 8
2
votes
2 answers

ReactiveSwift one vs multiple signal subscriptions and related memory overhead

I have a simple signal, in one of the app components, that returns an array of items: var itemsSignal: Signal<[Item], Never> Those items might contain updates for the data that are rendered on the screen in a form of a table view. The task is to…
danylokos
  • 1,464
  • 15
  • 20
2
votes
1 answer

What is the equivalent for PublishSubject in ReactiveSwift?

I am using ReactiveSwift in my project, and I'm wondering what is the equivalent for PublishSubject? for example in RXSwift we can do: let disposeBag = DisposeBag() let pubSubj = PublishSubject() pubSubj.on(.next("(next 1")) //event…
Maor
  • 3,340
  • 3
  • 29
  • 38
2
votes
1 answer

Enable/Disable button with validating phone number entered in a textfield

I'm very new to ReactiveSwift and MVVM as a whole. I'm trying to validate phone numbers entered into a textfield and enable/disable a button depending on the validation result. In the app, there is a textfield and a UIButton button called Submit.…
Isuru
  • 30,617
  • 60
  • 187
  • 303
2
votes
1 answer

Synchronising combined Properties in ReactiveSwift

I'm considering converting a project using my own custom signal framework to use ReactiveSwift instead, but there is a fundamental issue I've never figured out how to resolve in ReactiveSwift: As a simplified example, let's say you have two mutable…
Dag Ågren
  • 1,064
  • 7
  • 18
2
votes
2 answers

KVO not working for custom property of NSManagedObject

I have a subclass of NSManagedObject Folder with a state of Availability @objc enum Availability: Int16 { case unknown case available case unavailable } Folder has to do extra stuff (like delete related files) whenever it's availability…
2
votes
2 answers

How to generalize form inputs from properties using functional reactiveSwift?

When doing forms with fields i want to send if there is a change i often do let initialOrChangedName = Signal.merge( nameChanged.signal, self.viewDidLoadProperty.signal .map { _ in nil } ) where private let nameChangedProperty…
bogen
  • 9,954
  • 9
  • 50
  • 89
2
votes
1 answer

ReactiveSwift/ReactiveCocoa: How to use UIButton disabled styling but not when Action is in progress?

UIButton can be configured to use different styling, title, etc when the button is enabled or disabled, e.g. with UIButton.setTitle(String, forState:UIControlState). ReactiveCocoa lets me hook up a ReactiveSwift.Action to the button's…
Tikitu
  • 679
  • 6
  • 22
2
votes
2 answers

Transform objects with imageURL into objects with downloaded UIImage using reactive programming

I have an array of A objects. I would like to transform it into an array with objects of type B. But the tricky part is to download images in the meantime and do everything using RxSwift or ReactiveSwift. Do you have any tips how could I do…
Kris
  • 1,538
  • 2
  • 16
  • 27
2
votes
1 answer

How to combine three Signals using reactive cocoa in swift?

I have read the documentation, it looks like "and" isn't suitable to combine signals. Then, I have looked into "combineLatest" but it expects atleast one value is returned from each signal. My use case, is I have three separate signals, they have no…
coolly
  • 343
  • 1
  • 6
  • 16
1
2
3
8 9