fun <T : Any> LiveStream<T>.subscribe(stream: String, onChangeCallback: (T?) -> Unit): StreamObserver<T>
Subscribes to the given stream. The events are dispatched on the main thread. If stream already has data set, it will be delivered to the listener. You should call LiveStream.unsubscribe to stop observing LiveStream.
onChangeCallback
- Unit function with the observer which will receive the events.
Return
StreamObserver
Reference will be useful when you'll need to call a
method LiveStream.unsubscribe.