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
0
votes
1 answer

Map a SignalProducer that contains an error to return a NoError

I am working with ReactiveSwift 3.x in an iOS project and have been unable to map over an error provided by one SignalProducer into a different one. My NoError SignalProducer is: func foo() -> SignalProducer The function being called…
CodeBender
  • 35,668
  • 12
  • 125
  • 132
0
votes
1 answer

How to multi-cast the results of an in progress Action or start a new one

I have the following scenario - I am using ReactiveSwift's Action to trigger a network request in my app. This network request is potentially expensive due to the processing that is done on it's response. So, when a caller tries to apply the Action…
Arkcann
  • 618
  • 7
  • 15
0
votes
2 answers

Access last value from a SignalProducer when terminated

I have a signal producer, when it's terminated I would like to know if a value was sent, I only need the last one, seems so simple ... let myProducer: SignalProducer = getMyProducer() myProducer.on(terminated: { // I need the…
batsansierra
  • 315
  • 1
  • 12
0
votes
1 answer

Reset SignalProducer state based on timer and result

I have a SignalProducer producer that asynchronously sends Ints. I can sum the values with producer.scan(0, +) Suppose I want to reset the sum to 0 if it is > 10 and no other values have been sent for 1 second. My first attempt looked like…
Sebastian
  • 7,670
  • 5
  • 38
  • 50
0
votes
1 answer

ReactiveCocoa how to listen to change in data model properties

New to ReactiveCocoa here. I have a (MVVM) view model that represents a Newsfeed-like page, what's the correct way to listen to change in data model's properties? In the following example, startUpdate() constantly updates post. The computed…
Jack Guo
  • 3,959
  • 8
  • 39
  • 60
0
votes
0 answers

ReactiveSwift observers does not work when set up in initializers of NSObject subclasses

i hit a weird issue while working when I set up a observer in the initializer of a class, subclassing from NSObject and for whatever reason it's not getting called. I tried removing duringLifetimeOf operator and retaining with a disposable only to…
Manoj
  • 953
  • 2
  • 8
  • 24
0
votes
1 answer

Use of undeclared type 'SignalProducerType

I am new to ReactiveCocoa and ReactiveSwift, I am having task of update code from Swift2 to Swift4 after updating code i stuck in one point where I encountered error for "Use of undeclared type 'SignalProducerType'" not found do we have any…
Vinay
  • 171
  • 1
  • 7
0
votes
2 answers

CocoaPods installing ReactiveSwift/ReactiveCocoa incorrectly

I’m trying to install ReactiveSwift/ReactiveCocoa in a project and having no luck. At first I was puzzled over the weird errors Xcode reported about my attempts at ReactiveCocoa code: However, further examination indicates that Xcode is building…
0
votes
1 answer

QueueScheduler not firing when interval is set

This code doesn't print anything: func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { QueueScheduler.main.schedule(after: Date() + 1.seconds, …
Alexey Shvachka
  • 243
  • 2
  • 13
0
votes
1 answer

'String' is not convertible to 'String?'

Using ReactiveSwift, I've used the following code: let alertMessageProperty = MutableProperty(nil) ... .on(failed: { self.alertMessageProperty.value = $0.localizedDescription }) ... which means: self.alertMessageProperty.value is of type…
Mick F
  • 7,312
  • 6
  • 51
  • 98
0
votes
1 answer

How to limit producers from emitting events with property's existing value?

Does setting the value of a MutableProperty result in the producer emitting a new event with the same value? In other words, if I don't want new events with the same value, do I need to do this != check? let really =…
ozool
  • 94
  • 1
  • 9
0
votes
1 answer

How to trigger block from any of > 2 signal producers?

I see in How to trigger block from any of multiple signal producers? that 2 signal producers can be combined using combineLatest. But what if there's 3 or more signal producers, where you want access to all 3 values? I tried: let prop =…
ozool
  • 94
  • 1
  • 9
0
votes
2 answers

How to execute producerB if and only if producerA doesn't throw an error?

I am trying to work with the below scenario I have two producers A and B. producerB should execute only when producerA is executed successfully and also if producerA throws error, handle the error and stop there. So I tried something like…
coolly
  • 343
  • 1
  • 6
  • 16
0
votes
2 answers

How to trigger block from any of multiple signal producers?

How do I trigger one block of code whenever any of a set of SignalProducers change? In other words, how do I get rid of my current redundant code: property1.producer.startWithValues { (value) in // do stuff with property1.value and…
ozool
  • 94
  • 1
  • 9
0
votes
1 answer

Initializing a RAC ReactiveSwift Property that has multiple dependencies?

I am fairly new with using ReactiveSwift and ReactiveCocoa and I seem to have hit a road block regarding the proper way of initializing a Property that has a dependencies. For instance in the following code, I try to initialize a Property but i get…
Edward Lim
  • 763
  • 9
  • 31
1 2 3
8 9