Skip to content

Instantly share code, notes, and snippets.

@surajsau
Created July 18, 2019 11:48
Show Gist options
  • Select an option

  • Save surajsau/f4519512b732098e13dac857b35cc140 to your computer and use it in GitHub Desktop.

Select an option

Save surajsau/f4519512b732098e13dac857b35cc140 to your computer and use it in GitHub Desktop.
MVP to MVVM: DataObserver
class DataObserver<T>() {
var value: T? = null
set(value) {
field = value
observer?.invoke(value)
}
var observer: ((T?) -> Unit)? = null
fun observe(observer: (T?) -> Unit) {
this.observer = observer
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment