So basically I have a struct
struct MyStruct {
var foo : String = ""
var bar : String = ""
}
Now I want to do the following : Observe change in an RxVariable of MyStruct, so that whenever that variable is changed, we also have an observer to that variable, we will be able to get the new struct in that observer.
To be clear once again -
Class A
var stct : Variable<MyStruct>() // RxSwift variable
Class B :
let observer = instanceClassA.stct.asObserver().subscribe(onNext :
{(newStruct) in
// newStruct found here -
}
observer.dispose(by:disposeBag)
The reason I want this flow is : I want Class B
to know when Class A's
variable of myStruct
has changed with new values, as everytime myStruct
variable changes, foo
and bar
, will also change
Think it like Class B is an observer to Class A's variable of myStruct. Now I am learning RxSwift hence I want to utilise its reactive nature of approach. Also I think this is a fairly easy thing to do, but the problem is that I cannot make a Variable (read : Rx)
of MyStruct
P.S - I am using Swift 4.0 and RxSwift's latest version.
Any Help is highly appreciated.