Search code examples
swiftrx-swiftrx-cocoa

RxSwift Custom DataType Convertion without Binders


Im new to RxSwift and working on with one of the application. I had come across an issue where in my viewModel i get a custom DriverType(because of my algorithms or function calls which i needed in my case), say : Driver<MyOwnObjectType>. Now i want to convert this to MyOwnObjectType. I know i can do this by having the binders in the respective viewcontroller, like below ex:

    fileprivate var testing: Binder<MyOwnObjectType> {
       return self.rx.selfBinder {_self, _value in
       // value is the actual MyOwnObjectType
       // Can i able to return this value?
      }
    }

But now i want to avoid the above , just wanted to retrieve the value MyOwnObjectType, or is there any way to bind using some method and return the value we bind?

Thanks in advance.


Solution

  • This is very poor practice and really should be avoided.

    That said, if you really need it while refactoring to full RxSwift, you can bind to a BehaviorRelay and then use .value to get the current value out.