General questions should be asked on StackOverflow, not here. This room focuses on development of Binding.scala.
I do, I think. I want Busy to the basis for displaying a "Busy" indicator, so it has to be reified somehow.
(Note that I'm not using the @dom support; I don't have any time to rewrite the UI bits, but the logic behind it could plausibly be rewritting using Binding.scala.)
Busy
as a local state variable, like val answer = Var[Option[String]](None)
in https://thoughtworksinc.github.io/Binding.scala/#3 . But you still do not need a universal place that dispatches all events according to your global state.
val currentLocalState: Binding[S] = whatEverItComes
currentLocalState.each match {
case SomeSpecificState =>
<button onclick={ event: Event => getNextState(event, SomeSpecificState) }>A button for SomeSpecificState </button>
case AnotherSpecificState =>
<button onclick={ event: Event => getNextState(event, AnotherSpecificState) }>A button for AnotherSpecificState </button>
}
You problem it that your AuthorizationState
state is redundant, which make your code depend on mutable state. Also the state is dangerous and error-prone regardless whether you use Binding.scala
or not.
For ajax events, you could simple wrap a JavaScript's Promise
or a scala's Future
to a Binding
via JsPromiseBinding or FutureBinding and create derived binding expression from the it. I cannot see why you need an internal mutable state.