How to make simple Binding in MVVM in iOS
Issue #103
If you use MVVM
or any other kinds of helper classes, then there’s need to report back the result to the caller. In simple cases, without asynchronous chaining, RxSwift
is a bit overkill, you can just implement your own Binding
. Basically, it is just observer pattern, or closure in its simplest form.
1 | class Binding<T> { |
Then you can declare it like
1 | class ViewModel { |
Finally, this is how you listen to the result via callback
1 | override func viewDidLoad() { |