Skip to content

Instantly share code, notes, and snippets.

@xuhaibahmad
Created September 1, 2018 16:25
Show Gist options
  • Save xuhaibahmad/08352939d213b081eb8a16dff1b1f24c to your computer and use it in GitHub Desktop.
Save xuhaibahmad/08352939d213b081eb8a16dff1b1f24c to your computer and use it in GitHub Desktop.
A wrapper to make any property observable
import io.reactivex.subjects.BehaviorSubject
class ObservableProperty<T>(private val defaultValue: T) {
var value: T = defaultValue
set(value) {
field = value
observable.onNext(value)
}
val observable = BehaviorSubject.createDefault(value)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment