Skip to content

Instantly share code, notes, and snippets.

@dcampogiani
Created February 3, 2018 18:59
Show Gist options
  • Save dcampogiani/1eb74b2125073ac8a2f6cfcb5c580df4 to your computer and use it in GitHub Desktop.
Save dcampogiani/1eb74b2125073ac8a2f6cfcb5c580df4 to your computer and use it in GitHub Desktop.
class EitherActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_input)
val viewModel = ViewModelProviders.of(this)[EitherViewModel::class.java]
signup_button.setOnClickListener {
viewModel.validate(email.text.toString(), number.text.toString())
}
viewModel.validation.observe(this, Observer {
it?.fold(this::handleLeft, this::handleRight)
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment