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.

About Rx and RxSwift

Rx is a generic abstraction of computation expressed through Observable<Element> interface.

RxSwift is a Swift version of Rx.

It tries to port as many concepts from the original version as possible, but some concepts were adapted for more pleasant and performant integration with iOS/macOS environment.

Cross platform documentation can be found on ReactiveX.io.

Like the original Rx, its intention is to enable easy composition of asynchronous operations and event/data streams.

KVO observing, async operations and streams are all unified under abstraction of sequence. This is the reason why Rx is so simple, elegant and powerful.


Resources

2149 questions
1
vote
1 answer

Simple observable struct with RxSwift?

I'm trying to come up with a simple observable object in Swift and thought to use RxSwift. I couldn't find a simple example to do something like this: protocol PropertyObservable { typealias PropertyType var propertyChanged: Event<(PropertyType,…
TruMan1
  • 33,665
  • 59
  • 184
  • 335
1
vote
1 answer

Binding to a UIRefreshControl after network call

I am new to RxSwift and I was wondering how I would be able to "reactively" use a UIRefreshControl with a UITableView instead of the normal way of creating a target, and manually calling beginRefreshing() and endRefreshing(). For instance, say I am…
jacks205
  • 545
  • 8
  • 19
1
vote
1 answer

Send object to subscriber of RxSwift Action

I used to use ReactiveCocoa in Objective-C but I've since switched to RxSwift as I found it easier to understand than RAC4. However there's something I used to do in RAC that was useful: @weakify(self); [[RACCommand alloc]…
jwswart
  • 1,226
  • 14
  • 16
1
vote
1 answer

RxAlamofire + Combine Signals

I have a simple server request that I want to filter and generate a new Observable validating the request with the JSON data. I have to do this because even when my request is invalid, my server response returns status code 200. But I can filter…
Antonio Junior
  • 469
  • 6
  • 13
1
vote
1 answer

RXSwift User input on error and continuation

I'm quite new to RX and I'm trying to understand how I can continue a task, after an error which requires user input. A concrete example would be two factor authentication.. We have an auth-service and a protected resource. Logging in, we receive…
Jan
  • 1,827
  • 2
  • 16
  • 29
1
vote
1 answer

Testing ViewModel with RxSwift

I am using ModelView-ViewModel in the project I am currently working and using RxSwift, RxBlocking & RxTests. Currently I am attempting to test the ViewModel but having many troubles to get my head around this. So lets say I have an ExampleViewModel…
a.ajwani
  • 868
  • 1
  • 8
  • 21
1
vote
1 answer

delaySubscription doesn't work with rx_tap

This is a short version of my code which will reproduce the problem: import UIKit import RxSwift import RxCocoa class ViewController: UIViewController { @IBOutlet weak var button: UIButton! let disposeBag = DisposeBag() override func…
mschumacher
  • 205
  • 1
  • 8
1
vote
1 answer

Build error when binding a `RxTableViewSectionedAnimatedDataSource` to a UITableView

I'm getting the following error when using RxTableViewSectionedAnimatedDataSource to a UITableView's rx_itemsAnimatedWithDataSource(). Here's a screengrab of the error: Cannot invoke 'rx_itemsAnimatedWithDataSource' with an argument list of…
dornad
  • 1,274
  • 3
  • 17
  • 36
1
vote
2 answers

Combining an unkown number of Observables

I'm using RxSwift. I have an array of textfields that is dependent on which UI is visible; it could have 1, 3, or 4 textfields in the array. Iterating over the array, I create signals for each of them that maps it to a boolean indicating if the…
Chris
  • 7,270
  • 19
  • 66
  • 110
1
vote
1 answer

How to transform rx_tap of UIButton to a network request directly without sending the request in a nested subscribe?

Suppose that I have a UIButton loginButton, I want to send a network request while tapping the button with the following code: override func viewDidLoad() { super.viewDidLoad() let session = self.session // NSURLSession …
mrahmiao
  • 1,291
  • 1
  • 10
  • 22
1
vote
2 answers

Realm notification to RX block

I would like to hide my Realm implementation and instead of working on RLMNotificationBlock I would like to use RXSwift. Below how my method looks like now (RLMNotificationBlock is a block that takes String and RLMRealm): func…
Szu
  • 2,254
  • 1
  • 21
  • 37
0
votes
0 answers

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 framework? public extension Reactive where Base:…
Jiss
  • 3
  • 1
0
votes
2 answers

Cannot assign to property: 'self' is immutable error

private let selectedPhotos = BehaviorRelay<[PHAsset]>(value: []) private lazy var completeButton = UIBarButtonItem(title: "확인", style: .plain, …
Hees
  • 17
  • 4
0
votes
1 answer

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 below, but 10 empty cells are still appearing. I'm…
0
votes
1 answer

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 isPurchasing filter is false (to prevent multiple touches…
Jiss
  • 3
  • 1