Hi! Not sure if it's a good idea at all, but I'm t...
# rx
k
Hi! Not sure if it's a good idea at all, but I'm trying to merge a
Copy code
ReplaySubject
with a timer. Basically, I'm trying to retrieve Battery Infos every X seconds and monitoring plugged state. I tried the following code, but I end up with an Observable and not a Subject (which I use in my Battery BroadcastListener):
Copy code
ReplaySubject.create<BatteryEvent>(1).toSerialized()
            .mergeWith(
                Observable.timer(60, TimeUnit.SECONDS)
                    .map { instance<Context>().registerReceiver(null, IntentFilter(ACTION_BATTERY_CHANGED)).toBatteryStateChanged() }
            )
What should I do to retrieve a Subject?