| Start |
|---|
| Disposing After the subscription was created, it is important to manage its correct deallocation. The docs told us that If a sequence terminates in finite time, not calling dispose or not using addDisposableTo(disposeBag) won't cause any permanent resource leaks. However, those resources will be used until the sequence completes, either by finishing production of elements or returning an error. There are two ways of deallocate resources.
In the first case you manually pass the subscription to the You don't actually need to create In the second case, if the subscription time coincides with the |
| RxSwift basics FRP, or Functional Reactive Programming, has some basic terms which you need to know. Every piece of data can be represented as Usually Let's take a look at following marble diagram: In this example there is a stream of The diagram above shows a case where no data was emitted and Before we move on, there are some useful resources:
|
| Creating observables RxSwift offers many ways to create an So, the observables are created. They holds just one value and then terminates with success. Nevertheless, nothing happening after it was created. Why? There are two steps in working with The console will print: And if I interested only in working with data, which take place in If I want create an observable of many values, I use different operators: And finally, maybe I want an |
Bindings Using the We can bind data to any That’s an Rx wrapper around the |
| RxCocoa and ControlEvents RxSwift provides not only the ways to control your data, but to represent user actions in a reactive way also. RxCocoa contains everything you need. It wraps most of the UI components' properties into
Basically, you can work with them as usual: This is very important to use: as long as you use Rx, forget about the Ok, another example: suppose we have a textfield, a button, and a label. We want to validate text in the textfield when we tap the button, and display the results in the label. Yep, seems like an another validate-email task, huh? First of all, we grab the Here empty parenthesis show user taps. Next, we take what's written in the textField with Nice, we have a stream of strings to validate, emitted only when we need to validate. Any Done! If you need more custom logic (like showing error views in case of error, making a transition to another screen on success...), just subscribe to the final |
Read Article
https://develop.horje.com/learn/1434/reference