有什么方法可以创建一个 RxJava2Observable
来通知状态变化?像:
private var internalState = "state1"
val state: Observable<String> = Observable(...)
...
fun updateState(newState: String) { ... } // !!! attention: I need to notify all subscribers about this new state
然后在任何地方使用它,例如:
// observe on state
state.subscribe(...)
每次状态更新都必须调用此订阅