2017-08-10 60 views
2

我使用com.thoughtworks.binding:route:11.0.0-M4庫管理路由,到現在我被按照TODO example(提供項目的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 
}) 

但在版本使用,watchHash已被棄用,根據文檔,應該使用Route.Hash(state).watch()

所以,形式可以改寫爲以下幾點:

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() 

但我怎麼可以檢索(結合)當前待辦事項列表路由變化時?作爲參數給出的Var(todolist)現在是Route的內部值。 此外Route.Hash[]Binding[Unit],所以我不能檢索像這樣的值:route.bind.xxx

我錯過了什麼嗎?

謝謝:)

回答

1

嘗試route.state.bind.xxx

請參閱Route.Hash.state

+0

哦,是的,我錯過了。真的很簡單。 非常感謝您的快速回復。 – Chris