Last active
August 29, 2015 14:19
-
-
Save ncammarata/1831e3bcea38d45dc8ab to your computer and use it in GitHub Desktop.
v2
This file contains hidden or 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
store Tasks { | |
@tasks = [] | |
@undone <- @tasks.filter(task => !task.done) | |
makeTask(task) { return { title: title, done: false } } | |
addTask(newText) { @tasks.push(makeTask(newText)) } | |
clear() { @tasks = @undone } | |
} | |
view Task { | |
<h2>{^data.title}</h2> | |
<input type="checkbox" checked={^data.done} change={^change()}> | |
} | |
view Main { | |
@newText = "" | |
add() { Tasks.addTask(@newText); @newText = "" } | |
<h1>Todo List</h1> | |
<Task repeat[task]={Tasks.tasks} | |
data = {task} | |
change = {bool => task.done = bool} /> | |
<div.toolbar> | |
<div.undone> {Tasks.undone.length} tasks left</div> | |
<button click={Tasks.clear()}>clear completed</button> | |
</div> | |
<input enter={add()} sync={@newText} placeholder="New Task" /> | |
} |
natew
commented
Apr 16, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment