Skip to content

Instantly share code, notes, and snippets.

@stepango
Created July 19, 2018 08:43
Show Gist options
  • Save stepango/37eab3fcdf4de015574439e0e717712e to your computer and use it in GitHub Desktop.
Save stepango/37eab3fcdf4de015574439e0e717712e to your computer and use it in GitHub Desktop.
Observable fields mapping
val nameText = ObservableBoolean(nameHint) { it.isEmpty() }
fun <T: Any> ObservableBoolean(o: ObservableField<T>, f:(T) -> Boolean): ObservableBoolean {
return ObservableBoolean()
.apply {
o.observe {
this.set(f(it!!))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment