Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent behaviour with Vars.value #73

Open
threeseed opened this issue Jan 6, 2018 · 1 comment
Open

Inconsistent behaviour with Vars.value #73

threeseed opened this issue Jan 6, 2018 · 1 comment

Comments

@threeseed
Copy link

If you look at the Todo example there is frequent use of the value attribute of a Vars for example:

allTodos.value += Todo(title, completed = false)
for ((todo, i) <- allTodos.value.zipWithIndex)

So as someone new to the framework I assumed that I could use value within a for comprehension in combination with the scalaz workaround i.e.

import com.thoughtworks.binding.Binding.{Var, Vars}
import com.thoughtworks.binding.dom

case class SelectOption(label: Var[String], value: Var[String])
val options = Vars.empty[SelectOption]

@dom def render(): Unit = {
import scalaz.std.list._
 <select> {
   for (option <- options.value) yield {
      <option value={option.value.bind}>{option.label.bind}</option>
   }
 }
 </select>
}

However this causes the option.value and option.label bindings to fail with the "each instructions must be inside a SDE block" error. Changing the for loop to the following fixes the issue:

for (option <- options)

This is extremely confusing and inconsistent since you can use the value attribute for adding, deleting and some iterating (?) but not within a for comprehension.

@Atry
Copy link
Collaborator

Atry commented Jan 6, 2018

So what's your proposal?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants