2

I'm using com.thoughtworks.binding:route:11.0.0-M4 library for managing the routing, and until now I was implementing the thing by following the TODO example (available in project github):

Route.watchHash(currentTodoList)(new Route.Format[TodoList] {
  override def unapply(hashText: String) = todoLists.find(_.hash == window.location.hash)
  override def apply(state: TodoList): String = state.hash
})

But in the version used, watchHash has been deprecated, and according to doc, Route.Hash(state).watch() should be used instead.

So, the form can be rewritten as following:

val route = Route.Hash[TodoList](all /* all todo lists*/)(new Route.Format[TodoList] {
  override def unapply(hashText: String) = todoLists.find(_.hash == window.location.hash)
  override def apply(state: TodoList): String = state.hash
})
route.watch()

But how can I retrieve (bind to) the current todo list when route changes ? The Var(todolist) that was given as argument is now internal to the Route. Moreover Route.Hash[] is a Binding[Unit], so I can't retrieve value like this: route.bind.xxx.

Am I missing something ?

Thanks :)

Chris
  • 63
  • 4

1 Answers1

1

Try route.state.bind.xxx.

See Route.Hash.state.

Yang Bo
  • 3,586
  • 3
  • 22
  • 35