Questions tagged [rx-swift]

RxSwift's intention is to enable easy composition of asynchronous operations and event/data streams. Use this tag only for questions that are specific to the RxSwift - Reactive Programming paradigm, or those that require code in the language. Use the related tags [ios], [osx], [apple-watch], [cocoa-touch], and [cocoa] for (language-agnostic) questions about the platforms or frameworks.

Filter by
Sorted by
Tagged with
0 votes
1 answer
47 views

How to implement rxswift's methodInvoked function in the combine framework

I am currently using rxswift, but am studying the combine framework. I used the methodInvoked function a lot in rxswift. Is it possible to create functionality like methodInvoked method in combine ...
Jiss's user avatar
  • 3
1 vote
1 answer
34 views

Last visible cell in CollectionView disappears when updating first visible cell's content

I have a weird behavior using RxDataSources. I am using an RxCollectionViewSectionedAnimatedDataSource. I have a button inside each cell in the collection view, which reveals some content. This ...
paprika's user avatar
  • 165
2 votes
1 answer
40 views

Observable.create capture behaviour

Why does this result in an attempted read of an already deallocated reference when doing printOnSelf("onFire")? After subject!.startEmitter() call, there should be two references to the ...
MrKew's user avatar
  • 833
1 vote
1 answer
93 views

How to handle user interactions in subviews with iOS MVVM

For implementing MVVM with a table view controller, it is often to have a single parent view model and a bunch of child view models for each cell. Let's say each cell has a like button, and now the ...
Andy's user avatar
  • 33
1 vote
1 answer
52 views

How to properly scroll after cells were added/removed to UITableView with RxSwift

I have a view controller with tableView with one section and I am displaying data in it using RxSwift in a following way. I wanna scroll to bottom of the tableView (or to anywhere else) whenever the ...
MrKew's user avatar
  • 833
0 votes
1 answer
37 views

Ten extra UITableViewCellContentViews appear blank and stacked on top of each other in the TableView. Sometimes it happens, sometimes it doesn't

Ten extra UITableViewCellContentViews appear blank and stacked on top of each other in the TableView. Sometimes it happens, sometimes it doesn't. You mentioned that you have defined cells above and ...
yselimguner's user avatar
1 vote
2 answers
33 views

How to use the Rxswift handler the favorite button

I have a favorite Button, the button isSelected changed by the network data and tap the button. When the isSelected by tap the button, it need to request the favorite or unfavorite API, but when it ...
Terriermon's user avatar
1 vote
1 answer
31 views

How do I handle cancelling of publishers in Combine's Future functions?

In RxSwift you can create a reactive function something like this: func aFunc() -> Observable<Void> { return Observable.create({ emitter in let disposable = Observable ...
Joakim Sjöstedt's user avatar
1 vote
1 answer
50 views

RxSwift: Remove a row in UITableView without reloading whole table

I can achieve this when not using RxSwift by doing the following. It works great, plays needed animation on the row being removed and doesn't reload the whole table: let item = self.dataSource[(...
Mando's user avatar
  • 11.4k
0 votes
1 answer
50 views

How to test multiple events in RxTest

We are currently implementing unit tests for our ViewModel. When a requestInAppPayment Input request comes in from the view model, subscription is implemented only when the instance property ...
Jiss's user avatar
  • 3
0 votes
0 answers
40 views

RxFlow: how to implement deeplink navigation

The app is tab based app using RxFlow for shaping the navigation. From deeplink I have an understanding of what Steps are needed to get to tab 1 and push VCs from there. So, in my naivete knowing ...
Anton Tropashko's user avatar
1 vote
1 answer
22 views

RxSwift Subject.isDisposed maybe not reflecting the actual state?

Consider the following code: class RxDisposeTest : XCTestCase { func test_dispose() { var scope = DisposeBag() var subjects = [PublishSubject<String>]() let ...
funct7's user avatar
  • 3,417
2 votes
1 answer
179 views

Is there a reason for the differing behavior of the throttle operator in Combine and RxSwift?

I meet some problems using the throttle operator in Combine, it looks like Combine's throttle operator doesn't throttling the first two elements of the asynchronous sequence. The following is the code ...
Yasic's user avatar
  • 59
0 votes
1 answer
39 views

RxSwift blockingGet equivalent

I'm developing a quite old application and need to handle between new rx way and old legacy threads. I started using repository pattern where all is emitted in Observables. And now I wanted to use my ...
michalp's user avatar
  • 83
0 votes
1 answer
27 views

How to use an Enum to send different networkings in RxSwift

I'm a freshman in the RxSwift's world.Here is my circumstance: First of all,I have an Enum defines two states of my business. Then,I have 2 buttons,Tap button A, first I want to change the value of ...
Frank8888's user avatar
0 votes
1 answer
51 views

RxSwift Subjects to update UI

I have an app that uses the delegate method to communicate controllers with ViewModels. But I would like to start using reactive programming with RxSwift. The problem I have is that I don't know what ...
Santiago Padilla's user avatar
0 votes
0 answers
15 views

Reorder the content of BehaviourRelay<Array> without emitting

I have a situation at hand. I have a designerDress:BehaviourRelay<[MyCustomObjects]> Already implemented in code which drives few UI components. Now I have a requirement to reorder the array ...
amar's user avatar
  • 4,305
1 vote
1 answer
59 views

How to manually fire didChange event listener on UITextView with RxSwift?

This is how I defined observer for UITextView using RxSwift: mainView.descriptionTextView.rx.didChange.subscribe { [weak self, mainView] _ in self?.viewModel.description.accept(mainView....
Bartłomiej Semańczyk's user avatar
0 votes
1 answer
91 views

How to sort in chronological order in a list of events?

This code uses RxSwift import RxSwift struct Input { let loadTrigger: Observable<Void> } protocol UseCase { func getEventsLists() -> Observable<[EventsList]> func ...
Alessandro's user avatar
1 vote
1 answer
28 views

I sent and received data between viewControllers using rxswift, but the text of the button on the receiving side does not change

It is the partial of code I can post the full code if you want, but it's too long... final class FirstVC: UIViewController { private lazy var scrollView: UIScrollView private lazy var ...
leean's user avatar
  • 11
2 votes
1 answer
356 views

Unable to build a Swift package after adding the `RxSwift` package dependency: "product 'RxCocoa' not found"

I have created a new Swift package and trying to use the RxSwift dependency within it. I followed these instructions to add the dependency but my package is unable to build after this with the ...
Mando's user avatar
  • 11.4k
1 vote
1 answer
114 views

Rxswift: Disposing a subscription is not disposing

I am pretty new to Rxswift and i am facing a problem I have an Observable, i do the binding\subscription in the viewModel Init, the screen is reused soo the subscription happens every time init ...
swift_dande's user avatar
0 votes
1 answer
120 views

RxCocoa/RxSwift crash when accessing TableViewDataSourceNotSet tableView(_:cellForRowAt:)

I'm using RxCocoa and RxSwift to render a UITableView against an array provided by a BehaviorRelay. The code to bind the data is below: // MyViewModel: var itemList = BehaviorRelay(value: [MyItem]()) ....
Mando's user avatar
  • 11.4k
1 vote
1 answer
166 views

RxSwift) issue with subscribing to a completable event using flatMap

func someCompletable() -> Completable { return Completable.create { observer in observer(.completed) return Disposables.create() } } let buttonDidTap = PublishRelay<Void&...
SH KIM's user avatar
  • 35
1 vote
1 answer
24 views

Create a done button for RxPickerViewAttributedStringAdapter

self.genderSource = RxPickerViewAttributedStringAdapter<[[DKProfileOption]]>.init(components:[]) { dataSource, pickerView, components in return 1 } numberOfRowsInComponent: { [weak self] ...
yselimguner's user avatar
1 vote
1 answer
41 views

Why does the second subscriber receive all the elements in RxSwift?

I currently have the following code. Both listeners are able to receive all 5 emitted values. However, I am confused, shouldn't the second listener miss the first few elements? import RxSwift import ...
AlanSTACK's user avatar
  • 5,545
1 vote
1 answer
241 views

How to convert Observable<Type> to Single<Type> in RxSwift?

I currently have a method that returns an observable. However, it only ever returns one element. func getMyResponse(queryID: String) -> Observable<Response> { return observable } I am ...
AlanSTACK's user avatar
  • 5,545
3 votes
1 answer
807 views

How to fix: "Type of expression is ambiguous without more context"

I encounter error while compiling the code: Type of expression is ambiguous without more context The funny thing is that it is working on a different machine. I see a couple of other posts about ...
Baal's user avatar
  • 77
0 votes
1 answer
141 views

Getting Urlsessiontask failed with error: the request timed out with blank screen RxSwift in swift

I am using RxSwift in swift. When my server is close it shows below error with blank screen. I have used a alert. But I have to click too many time to close the alert here is the error I have ...
Enamul Haque's user avatar
  • 4,785
3 votes
2 answers
225 views

Referencing instance method 'xxx' on 'PrimitiveSequence' requires the types 'A' and 'any B' be equivalent

We need some advice. I'm trying to do such abstraction so I have many different Response's. At some time in the project we realized that some of our Responses have id property and we want to make some ...
Marcin Kapusta's user avatar
2 votes
1 answer
148 views

RxSwift call function for elements of array

I have an array of devices, I want to try to connect to one of the devices, if it is successful stop trying to connect to other devices and return onCompleted, if the connection fails to the device, ...
eXceLLenT's user avatar
1 vote
1 answer
60 views

Skip events from source sequence until a task finished

I have a PublishSubject as source sequence. I need to do a api call on receiving events. Imagine if this is emitting events too fast, I want to skip all the events until api call finish. After API ...
smartsanja's user avatar
  • 4,413
1 vote
1 answer
356 views

How to handle success case and failure case for multiple API calls when using Observable zip in RxSwift

I call two independent API calls using Obeservable.zip(). In this case, if the first API fails(returning some kind of error), the second API never executes inside the subscribe(onNext) closure even if ...
akaakoz's user avatar
  • 248
0 votes
1 answer
105 views

Can you avoid closure memory leaks by using functions instead?

So I'm using RxSwift and has a function that looks like this: private func setAndVerifyTestmode(isOn: Bool) { parameterService.setTestMode(value: isOn) .flatMap { _ in self.parameterService....
Joakim Sjöstedt's user avatar
1 vote
1 answer
78 views

How to create RxSwift sequence based on selected UIButtons?

I am new to RxSwift. I have 3 UIControls on the screen. Selecting one or all controls should enable the "Next" UIButton at the bottom of the screen. I don't understand how: How to create ...
nsus's user avatar
  • 13
1 vote
1 answer
122 views

How to Disable the button tap in 5 seconds by using rxSwift?

rxSwift version: pod 'RxSwift', '6.2.0' pod 'RxCocoa', '6.2.0' TrueBtn.rx.tap.throttle(.seconds(5), scheduler: MainScheduler.instance) .subscribe(onNext: { [weak self] in print("TrueBtn-true&...
jiexishede's user avatar
  • 2,483
1 vote
1 answer
57 views

Subscribe cancels the subject when the source publisher completes

I have a function which receives a Publisher and creates a PassthroughSubject that is used to both: subscribe to the source publisher send values manually E.g.: class Adapter<T>{ let ...
NSMustache's user avatar
2 votes
1 answer
897 views

Missing Required Module 'RxCocoaRuntime'

I am using RxCocoa in custom framework, so I am trying to inject dependencies with SPM and make that .xcframework. I made the .xcframework, but the following error keeps appearing. The process of ...
KMBANG's user avatar
  • 21
2 votes
1 answer
248 views

Observable sequence called several times on retryWhen, but should call only once

I am trying to build RxSwift Auth token refresh service using following tutorial: https://www.donnywals.com/building-a-concurrency-proof-token-refresh-flow-in-combine/. However, I faced with issue, ...
Richard's user avatar
  • 97
1 vote
1 answer
85 views

SwiftUI Combine synchronously execute codes

I call an API and perform some actions based on the response. let test = apiPublisher .subscribe(...) .receive(...) .share() test .sink { //do task1 }.store(...) test ...
arun siva's user avatar
  • 819
1 vote
1 answer
46 views

How to make restartable countdown using Rxswift

I want to create a countdown feature that restart every time I press a button. However, the code I wrote terminate the subscription when the countdown is completed. What can I do to ensure that my ...
ChanSeul's user avatar
1 vote
1 answer
77 views

Swift UIAlert doesn't waiting user response

func permissionInit() { Task{ addListViewModel?.cameraPermission.accept(await chkCameraPermission()) addListViewModel?.photoLibraryPermission.accept(await ...
hong4383's user avatar
1 vote
2 answers
524 views

Unit testing void function in Swift

I am new to unit testing. I am using MVVM in my project. I also use RxSwift to pass data or communicate between view and ViewModel. I don't understand how I can write unit tests in my case. Any ...
Md. Sulayman's user avatar
0 votes
1 answer
71 views

Hide UIButton after click in RxSwift

I need to hide UIButton just after it clicked using RxSwift. I'm not getting any way to do this. Need help here!
Muneesh Chauhan's user avatar
6 votes
3 answers
2k views

Creating an Observable around an async/await method using RxSwift

I am using the AWS Amplify library https://github.com/aws-amplify/amplify-swift to communicate with the Cognito service. Most of the functions have been rewritten using the new async/await approach. ...
Florian Ldt's user avatar
  • 1,145
0 votes
1 answer
349 views

RXSwift - Waiting multiple API or task to finish

I am new to RxSwift and I would like to achieve something like this. Here's the situation I have 2 different APIs that needs to populate in a UITableView. Therefore I need to combine 2 sets of data I ...
cMoNz's user avatar
  • 13
0 votes
1 answer
51 views

Reverse binding to parent view model from child view model

I have a main view model called CustomizeMenuItemViewModel which has a property maxItemCount which needs to be decreased to 0 whenever the user interacts with the view to add one item in the shopping ...
Aashima Anand's user avatar
0 votes
0 answers
73 views

Making MapBox annotation delegate RX compatible

I need to find the way to make MapBox delegates fully reactive, just like some many native ones. I managed to make MapBox annotations bindable by subscribing PointAnnotationManager to ...
13thApostle's user avatar
1 vote
1 answer
219 views

iOS RxSwift make event view based on observable array data

Hi I prepare ios developer Sorry, because do not speak english not well I would like to know how to implement it in general. subscribe array data and make custom view doTableViewModel.doItems ....
Cook Kim's user avatar
1 vote
1 answer
126 views

Combine array of object from different endpoint so it can also pagination

I have 2 different endpoint: The first one have a pagination. The second one doesn't have pagination I mapping the object from the first and second endpoint so they have the same object when i ...
ferryawijayanto's user avatar

1
2 3 4 5
43