Questions tagged [reactive-cocoa]
ReactiveCocoa (RAC) is a Swift framework inspired by Functional Reactive Programming. It provides APIs for composing and transforming streams of values.
860
questions
0
votes
1
answer
57
views
What is correct way to make a UIButton change a MutableProperty?
The following code works:
import UIKit
import ReactiveSwift
import ReactiveCocoa
class ViewController: UIViewController {
let myAction = Action<UIButton, (), Never> { _ in
return ...
0
votes
2
answers
92
views
Reduce array of properties ReactiveSwift
I have an array of Property<Int>, and I need to reduce them to get sum of the last inputs (it's basically an unread notification counter from different SDK's) and put that into new Property<...
0
votes
0
answers
52
views
Migrating from ObjC KVO to ReactiveSwift
I'm trying to migrate some parts of a project that was initially written in Obj-C. Currently I'm trying to migrate a code that relies heavily on signals. To give you a general idea of what I'm trying ...
1
vote
1
answer
161
views
How to map a completed event to an interrupt event when take(duringLifetimeOf:) happened in ReactiveSwift
For example, I want to send a request in my viewModel, if the viewModel is dealloc. The request signal should send interrupt event.
This is my code
func request() -> SignalProducer<Data, Error&...
0
votes
1
answer
84
views
MultiThreaded delaying class deallocation
below i am defining a solution and using interval as a timer in background thread as follow :
@weakify(self)
//IMPORTANT:- Throttle is working exactly the same way debounce works in RX SO DO NOT USE ...
0
votes
2
answers
2k
views
when I run this NPX POD-INSTALL it gives me this COCOAPODS IS NOT SUPPORTED IN THIS PROJECT #ReactNative
Package.json
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --...
13
votes
3
answers
10k
views
Combine previous value using Combine
How can I rewrite ReactiveSwift/ReactiveCocoa code using Combine framework? I attached screenshot what combinePrevious mean from docs.
let producer = SignalProducer<Int, Never>([1, 2, 3])....
0
votes
1
answer
235
views
Should I check the existence of weakself before use @strongify(self) in ReactiveObjc?
As the other practice in weak and strong, it recommends that we should check whether the weakself is null before we strongify it. It looks like this:
__weak weakself = self
someblock {
if (weakself)...
0
votes
1
answer
443
views
Ambiguous use of operator '<~' in ReactiveSwift
I inherited a somewhat old project written in ReactiveSwift (v3.1.0) and ReactiveCocoa (v7.2.0). When I opened it on Xcode 10.1, it was built without an issue. But when I did the same on Xcode 10.3, I ...
0
votes
1
answer
156
views
'() -> BindingTarget<Error>' is not convertible to '(Bool) -> BindingTarget<Error>'
I recently inherited a iOS project written using ReactiveSwift 3.1.0 and ReactiveCocoa 7.2.0. I'm tasked with updating it to Swift 5 and the latest ReactiveSwift versions.
I updated ReactiveSwift to ...
0
votes
1
answer
265
views
Dont complete on fail in Reactive Swift
I have a function capturing events from an api which works great. The only issue is i dont want the stream to be complete when it fails.
public func getDeviceEvent(deviceUID: String) -> ...
1
vote
0
answers
332
views
How to use SignalProducer.timer for ReactiveCocoa 9.0
I'm working on updating an app from Swift 3 to Swift 5. This requires updating ReactiveCocoa. There is some code that was using a timer within a SignalProducer that no longer works when updating. Here ...
0
votes
1
answer
1k
views
rx.sentMessage(#selector(UIViewController.viewDidLoad)) is not firing
I have an app using RxSwift following MVVM.
ViewController
import UIKit
import RxSwift
import RxCocoa
final class ProfileViewController: BaseViewController<ProfileView> {
var viewModel: ...
1
vote
1
answer
94
views
Designing observable objects
Preface: this is a design question about reactive programming. It's intended to be language agnostic, so it's all psuedo-codey. I suspect whatever the right answer is, would be equally applicable ...
0
votes
1
answer
95
views
reactivecocoa rac binding bool array to set mutilple uilabel text
I have a statusArray and to show the UILabel texts
based on the Bool value
say , 1 show someString
then 0 show some other string
how should I do that use rac as ReactiveCocoa ?
0
votes
1
answer
186
views
How create date schedular?
I am trying to create a date scheduler to observe some event. But it does not work. I've looked through
protocol DateScheduler
and it is said that action will take place at currentDate in some ...
0
votes
1
answer
57
views
how to use swiftReactive watching an method with some param when it use?
sorry my English not verywell,in swift i want to use SwiftReactive do something ,like in ObjectC the RAC work,like:
[[a rac_signalForSelector:@selector(xxxx)] subscribeNext:^(id x) {
}];
and in ...
15
votes
1
answer
6k
views
RxSwift -- MainScheduler.instance vs MainScheduler.asyncInstance
What is the difference between using RxSwift's MainSchedule.instance and MainSchedule.asyncInstance within the context of observeOn?
2
votes
1
answer
732
views
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 ...
0
votes
1
answer
120
views
Why observeValues block not called?
Try to use ReativeSwift on my project, but something not perform well
I have check many times, cant find out what's wrong.
Everything is right, and it just not called.
class MSCreateScheduleViewModel:...
0
votes
1
answer
618
views
How can I better combine this 2 values that consume the same Publish Subjects
I am learning RxSwift.
I have setup a view model that responds to bindings in my ViewController.
isValid checks both a username and password exist and then enables my login button.
...
8
votes
2
answers
905
views
Error with latest ReactiveCocoa Carthage : No such module 'Result'
I'm updating my project to Swift 5 Xcode 10.3.
Everything was working fine with the previous Swift version now with the latest ReactiveCocoa 10.0.0
Already tried :
Deleting and updating all ...
1
vote
1
answer
141
views
Reactive Cocoa MVVM Initialization
So I'm fairly new to the concepts of Reactive Swift/Cocoa & MVVM. I'm wondering If I have the ViewModel initialized in the wrong place.
Model
struct userInfo {
let name: String
let birthday: ...
2
votes
1
answer
1k
views
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 ...
0
votes
1
answer
729
views
How to dispose DisposeBag when using ViewModelOwners with ReactiveCocoa
ViewModelOwners documents how to use with ReactiveCocoa CompositeDisposable
The Example is even implemented with ReactiveCocoa.
However, I do not understand how the disposeBag is actually disposed ...
3
votes
2
answers
715
views
ReactiveSwift: Observe Managed Object changes with MutableProperty
My project has CoreData database with 1 root context and multiple sub contexts.
I have a ViewModel that contains an Item (NSManagedObject). When I changes something in an Item the persistence is made ...
0
votes
1
answer
70
views
RACChannelTerminal on UISlider when is the nil override used
When does the nil value override come into play here:
RACChannelTerminal* sliderTerminal = [self.view.volumeSlider rac_newValueChannelWithNilValue:@0];
When the slider is receiving nil from the ...
1
vote
1
answer
147
views
How to turn a Property<Int> into a SignalProducer<Int, PossibleError>?
Given
let numberOfSneezes = Property<Int>(0)
how do i turn numberOfSneezes.producer into this type of producer
let sneezeNumberProducer: SignalProducer<Int, PossibleError>
?
I know ...
1
vote
2
answers
2k
views
How to Synchronize or make an Observable wait on Swift?
So, i have this login function, where i want to return a Boolean to my .xib controller, where it has to make some modifications, according to the success of the login.
func login(cpf: String) -> ...
1
vote
1
answer
46
views
How to bind enumerate variable changed in objc?
I'm ready to migrate my project to RAC,but there is a error that when I want to bind a property's change.
#import <UIKit/UIKit.h>
@interface XBXMLoginTextField : UIView
@property (nonatomic, ...
0
votes
1
answer
175
views
ReactiveCocoa memory leak - CocoaAction of UIButton prevents MVVM object deinitialization
I'm using MVVM + ReactiveCocoa.
My code works as expected. Except ViewModel object had stayed in 'Debug Memory Graph' when I removed ViewController from parent.
ViewController deinited, unlike ...
-1
votes
1
answer
144
views
How to use rac_signalForControlEvents
How can I convert same method "rap_signalForControlEvents" to last working ReactiveCocoa Version?
I'm trying to build a example of the book Reactive programming with swift, but when I implemented ...
1
vote
0
answers
37
views
reactivecocoa confuse about sequence.array
I want to get grouped array from [1, 2, 2, 3, 3, 3, 4, 4, 4, 4] to [[1], [2, 2], [3, 3, 3], [4, 4, 4, 4]].
I've written two types of code. The first one works fine, but the second one doesn't. anyone ...
2
votes
2
answers
837
views
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 ...
0
votes
1
answer
264
views
ReactiveSwift with MVVM and Action
code :
init(roomService: RoomService) {
self.roomService = roomService
let viewDidLoad = viewModelProperty.signal.skipNil()
roomAction = Action<(), [Room], NetworkError>(execute: {...
0
votes
1
answer
705
views
Merge two streams with flatMapLatest
having a problem with combining to observables in flatMapLatest
Logic: on every activity next event, I want to combine it together with the next getCurrentLocation event, which happens after ...
0
votes
1
answer
282
views
Reactive cocoa forcing a synchronous function to wait for reactive callback
I did a lot of research and haven't got any answer for this one.
this is my code:
fileprivate var dispose: ScopedDisposable<AnyDisposable>?
func connectToServer() {
...
let user = ...
2
votes
1
answer
1k
views
iOS MVVM handling initial view state
I am trying to use MVVM without Rx in Objective C, basically something like MVP. I have some very basic doubts that I would like to clear
1.) How to load the initial view state in view, based on ...
1
vote
1
answer
1k
views
ReactiveSwift emit elements from an array with a delay between elements
Let's say I have an array of elements [1, 2, 3] and a delay of 5 seconds.
I want to emit each element of the array with a pause between the current element emited and the next.
Example:
Output:
[...
1
vote
2
answers
1k
views
ReactiveSwift Refresh data
I beginner in ReactiveSwift. This is fetching code in my view model :
private let viewDidLoadProperty = MutableProperty<Void?>(nil)
public func viewDidLoad() {
disposables += self....
0
votes
1
answer
689
views
API Request in ReactiveSwift
I am beginner in ReactiveSwift. I create weather app and my request does not work.
func fetchCurrentWeather() -> SignalProducer<TodayWeatherData?, DownloadError> {
guard let unwrappedURL ...
0
votes
1
answer
205
views
Convert Reactive Cocoa Code to RxSwift?
For this code
fileprivate let nameChangedProperty = MutableProperty("")
public func nameChanged(_ name: String) {
self.nameChangedProperty.value = name
}
What I did
fileprivate let ...
0
votes
1
answer
288
views
RxSwift - Concat only on condition
I have 2 stream which are being concatenated. If the first stream executes onError instead of onComplete, I shouldn't be concatenating the second stream.
example:
func updateEntity(entities: [Member]...
1
vote
0
answers
529
views
Unit Testing ReactiveCocoa SignalProducer keeps coming back interrupted
Ive been unit testing ReactiveCocoa Signals and Producers using XCTest expectations for a project im working on. For one some reason (I suspect after a pod update) my tests started failing and ...
0
votes
1
answer
1k
views
Ambiguous reference to member 'flatMap'
I'm trying to use the ReactiveCocoa library. But when I use the ReactiveCocoas flatMap function, I get an error. Does anyone know how to get around it? Maybe I'm doing something wrong?
let ...
2
votes
1
answer
395
views
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 ...
0
votes
1
answer
984
views
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 ...
3
votes
2
answers
179
views
Mock a Reactive<UISlider>?
I have a ViewModel which has as an input in its initializer
init(sliderEvents: Reactive<UISlider>) {
In the test i want to do something like
slider.send(.touchDownInside)
slider.send(....
5
votes
1
answer
2k
views
How can I transform a signal with errors into a NoError one with ReactiveSwift? (and be elegant)
What is the most elegant way to transform my ReactiveSwift's SignalProducer<A, NetworkError> into a Signal<A, NoError>?
Most of the time, my signal producer is the result of a network ...
2
votes
1
answer
2k
views
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 ...