Search code examples
iosbindrx-swiftrx-cocoa

Does binding order matter when binding multiple operations to a single control event?


When binding two specific operations to a button tap, does execution order follow binding order?

For example, in the following code, is there a way to tell what gets executed first?

self.resetButton.rx.tap.bind(to: viewModel!.resetPasswordButtonObserver).disposed(by: disposeBag)

self.resetButton.rx.tap.bind {[weak self] in
    self?.loader.lock()
}.disposed(by: disposeBag)

In my code, the viewModel calls an API and executes the reset operation before the self?.loader.lock() block is executed, which may cause problems for really fast connections.


Solution

  • Unless you change the thread that the code executes on, it will execute in the order you wrote it.