I'd like to create an observable in a singleton class that manages state (i.e. it stores an auth token). I'd like my android app/activity to subscribe to an observable that will emit an update every time the state (auth token) is updated. How do I do this? All examples I've seen show how you can create a self contained observable that completes immediately or after subscription.
Thanks for your help!
You need a
BehaviorSubject
.If you want to set the state from multiple threads concurrently, you need this as the first line.