I’ve a singleton class referred to as UserIDManager
that generates a consumer id as a string and move it to some strategies and I’m utilizing it like this:
UserIDManager.shared.userID
I’ve one other class referred to as UserManager
that passes userID to analytics. And this occurs when the app willEnterForegroundNotification
Now I have to subscribe to the userID
within the init()
of the consumer supervisor after which ship it to analytics each time it adjustments. I’m not accustomed to RxSwift very effectively, however on my take a look at undertaking, it is not going to replace or print any new id when getting into the foreground.
Right here is my code:
UserIDManager.shared.rx
.observe(String.self, "userID")
.compactMap { $0 }
.distinctUntilChanged()
.subscribe(onNext: { userID in
self.userIDLabel.textual content = userID
print(userID)
})
.disposed(by: disposeBag)
any assist could be appreciated.