So I’m back with yet another question regarding observables, since I can’t figure out how they work and I don’t seem to understand So what I’m trying to achieve is having an observable that starts with a default value, waits 5 seconds, then changes that initial value and emits it. I tried using BehaviorSubject, but it doesn’t seem to do the trick (or again, I’m missing something out) Here’s my code so far:
fun printLog() { val observable = BehaviorSubject.createDefault(false).delay(5, TimeUnit.SECONDS) observable.apply { observeOn(AndroidSchedulers.mainThread()) Log.e("STH", "NANANANANA") Toast.makeText(applicationContext, "blah blah", Toast.LENGTH_SHORT).show() subscribe { Log.e("EEEE", "delayed") //setValue(true) ??? } } }
Any suggestions would be greatly appreciated 😊
submitted by /u/LilienSixx
[link] [comments]