Questions tagged [rx-cocoa]
238 questions
34
votes
7 answers
RxSwift: How to add gesture to UILabel?
I have a label with isUserInteractionEnabled set to true. Now, I need to add UITapGestureRecognizer for the label. Is there a way to add in Rx way.
I have looked at the RxSwift library here. Which they didn't provide any extension for adding…

Rugmangathan
- 3,186
- 6
- 33
- 44
27
votes
3 answers
Observing UITextField.editing with RxSwift
I want to observe the property UITextfield.editing. I'm using this code:
self.money.rx_observe(Bool.self, "editing").subscribeNext { (value) in
print("")
}.addDisposableTo(disposeBag)
But in the process of running, it's only performed once. How…

C.liu
- 273
- 1
- 3
- 5
19
votes
1 answer
RxSwift/RxCocoa: prevent UITextField from having more than ... characters
I would like to have a UITextField configured with RxSwift/RxCocoa so that it only contains up to ... characters. I do not want to use the UITextFieldDelegate for this but would love to achieve this with RxSwift/RxCocoa. Is there a way to do this?

swalkner
- 16,679
- 31
- 123
- 210
18
votes
3 answers
RxSwift modify tableview cell on select
I have a table view in my app. I generated the datasource for this table using following code
struct ContactNameNumberBlockStatus {
var contactThumbnail: Data?
var contactName : String
var contactNumber: String
var blockStatus :…

LynAs
- 6,407
- 14
- 48
- 83
17
votes
1 answer
rxswift bind(onNext: VS subscribe(onNext:
I have 2 questions:
What difference between 'bind(onNext:' and 'subscribe(onNext:'?
struct Info {
var index: Int?
var data: String?
}
let infoData: BehaviorRelay = BehaviorRelay(value: Info())
var osInfo: Observable {…

dh0rmfpdlxm
- 301
- 1
- 3
- 16
13
votes
1 answer
flatMap Not returning onCompleted
I have created below function with chaining of multiple observables however whatever I do it does not seem to call completed ? it only return the following:
(facebookSignInAndFetchData()) -> subscribed
(facebookSignInAndFetchData()) -> Event…

Peter Pik
- 11,023
- 19
- 84
- 142
12
votes
1 answer
Difference between `.drive()` and `.bind(to:)`
I am learning RxSwift at the moment.
When would you use .drive(something) and when .bind(to: something)?
Example:
let disposeBag = DisposeBag()
let isEnabled = BehaviorRelay(value: true)
let button = UIButton()
// what is the benefit of…

Dich1944
- 141
- 1
- 6
12
votes
2 answers
RxCocoa - Why doesn't PublishRelay have an asDriver() method?
On RxCocoa I was wondering why the PublishRelay doesn't have an asDriver() method like the BehaviorRelay ? Currently if I want to convert the publishRelay into a Driver, I have to specify what to return in case of error which seems weird given that…

Bioche
- 458
- 4
- 11
12
votes
3 answers
RxSwift double mapping in tableView.rx.itemSelected
I want to get object from tableView.rx.itemSelected and after process it. This method return IndexPath, so I can map this value. But how to get object at index from the ViewModel?
struct ViewModel {
var items: Observable<[Item]>
}
Approximate I…

biloshkurskyi.ss
- 1,358
- 3
- 15
- 34
10
votes
2 answers
RxSwift: What is the best practice to use DisposeBag?
Now I need to change the app theme(colors) based on configuration API, So I am using RxCocoa, RxSwift frameworks to create observable on each view controller to apply a new theme on the app.
My question is what is the best practice for using…

Moayad Al kouz
- 1,342
- 1
- 9
- 19
9
votes
1 answer
Changing the text of a UITextField does not trigger the rx.text binder
I have a UITextField called commentField and I create an Observable like this:
let isCommentFieldValid = self.commentField.rx.text.orEmpty.map({ !$0.isEmpty })
This observable determines whether a button is enabled or not.
The problem is that…

Kévin
- 850
- 7
- 13
9
votes
2 answers
issue with having rx.tap for UIButton in UICollectionViewCell - RxSwift 3
I am subscribing 2 times for 1 UIButton :
First subscription, for updating UI on every click
Second subscription, for updating the values on Web Service every 1 second after accumulated clicks.
Code:
class ProductionSize {
var id : Int?
…

MBH
- 16,271
- 19
- 99
- 149
8
votes
2 answers
TabelView Delegate methods using RxSwift
I am using RxSwift for TableView.I need to calculate height of dynamic cells previously I did it in WillDisplayCell delegate method. I don't know how to bind TableView Delegate methods with RxSwift. Can any one help?

Mehreen
- 501
- 3
- 6
- 11
8
votes
3 answers
Reload Tableview using RxSwift
I am using RxSwift for tableview. I need to reload my table each time after getting data from api but I'm failed to do this. I couldn't find any solution for that. Can anybody help?
I have an array of places obtain from response of an Api.I have…

Mehreen
- 501
- 3
- 6
- 11
8
votes
1 answer
RxSwift Build an Observable based on a Variable
I am trying to build an Observable which would output a value based on the value of a Variable.
Something like that:
let fullName = Variable("")
let isFullNameOKObs: Observable
isFullNameOKObs = fullName
.asObservable()
…

t4ncr3d3
- 615
- 1
- 8
- 17