def attemptLogin(): Ui[Any] = {
if (password.get.getText.length == 0 || password.get.getText.length == 0) {
toast("Provide username and password") <~ fry
} else {
val loginResult = service.login(username.get.getText.toString, password.get.getText.toString)
loginResult.onComplete {
case Success(token) =>
// do something
case Failure(t) =>
error(s"Login failed '${t.getMessage}'", t)
Ui {
toast(s"Login failed: ${t.getMessage}") <~ fry // <---- this doesn't appear
}.run
}
Ui{}
}
// when creating view
w[Button] <~ wire(signIn) <~ text("Sign In") <~ On.click({
attemptLogin()
})
However, the toast never appears, even though the execution path is invoked (I see the "Login failed ..." in logs).
I also tried `runUi { toast("...") }` with same results.
login method is a 'dispatch' HTTP library call.
Regards,
John