<@U0BFDUP0E> I am using some old voip api, in whic...
# rx
@jw I am using some old voip api, in which I need to get duration of the call as a observable (i.e. 0000…0001...00:02 etc), since it doesnr provide any push api, only getCallDuration()… i need to poll it every second, so I do that via Interval + map. This is all happening in a Service, so I cant just keep direct references, so I am using a separate object which basically just wraps a relay, has a setter + observable getter So by default that interval observable hosted by Service will run regardless of whether UI is present, api is clean, but I want to optimize this (might be bs to optimize, if it involves too mucj code) Id like for the interval only to emit when UI is there. So i need to stop it if ui goes away and restart it when it comes. So i need a observable that tells me when UI came and went.
Copy code
.switchMap { if it == true empty() else interval().map { voip.getCallDuration() }}