Advertisement
Guest User

Untitled

a guest
May 26th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. store Tasks {
  2. @tasks = []
  3. @undone <- @tasks.filter(task => !task.done)
  4.  
  5. makeTask(task) { return { title: title, done: false } }
  6.  
  7. addTask(newText) { @tasks.push(makeTask(newText)) }
  8. clear() { @tasks = @undone }
  9. }
  10.  
  11. view Task {
  12. <h2>{^title}</h2>
  13. <input type="checkbox" checked={^done} change={^change}>
  14. }
  15.  
  16. view Main {
  17. @newText = ""
  18.  
  19. add() { Tasks.addTask(@newText); @newText = "" }
  20.  
  21. <h1>Todo List</h1>
  22. <Task[Task.tasks] change = {bool => task.done = bool} />
  23.  
  24. <div.toolbar>
  25. <div.undone> {Tasks.undone.length} tasks left</div>
  26. <button click={Tasks.clear()}>clear completed</button>
  27. </div>
  28.  
  29. <input enter={add} sync={@newText} placeholder="New Task" />
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement