Created
September 30, 2015 21:19
-
-
Save pjazdzewski1990/a23d3988759aa8b32ca7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@JSExport | |
def main(target: html.Div): Unit = { | |
... | |
/// create a chain of reactive variables | |
val mouseVar = everyClick(addButton) | |
val addTodo = Obs(mouseVar) { | |
val desc = addDesc.value | |
val time = Try{ addTime.value.toInt }.toOption.getOrElse(0) | |
println(s"Adding $desc/$time") | |
addNewTodo(desc, time) | |
} | |
val timeVar = everySecond() | |
val todoTimeCount = Rx { | |
thingsToDo().foldLeft(0)((x, y) => x + y.time) | |
} | |
val todoCount = Rx { | |
thingsToDo().length | |
} | |
val updateTimeSummary = Rx { | |
refreshTimeSummary(timeVar(), todoTimeCount()) | |
} | |
val updateTimeSummaryStyle = Rx { | |
val count = todoCount() | |
if(count >= 5) { | |
timeSummary.style.backgroundColor = Color.Red | |
} else { | |
timeSummary.style.backgroundColor = Color.White | |
} | |
} | |
val updateTodoList = Rx { | |
refreshTodoList(target, thingsToDo()) | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment