Created
September 1, 2018 16:25
-
-
Save xuhaibahmad/08352939d213b081eb8a16dff1b1f24c to your computer and use it in GitHub Desktop.
A wrapper to make any property observable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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