                  constants.CLEAR_TODOS, @onClearTodos)
 
   onAddTodo: (payload) ->
-    id = @_nextTodoId()
+    id = @_nextTodoId
     todo =
       id:       id
       text:     payload.text
       complete: false
-
     @todos[id] = todo
     @emit 'change'
 

  toggleTodo: (id) -> @dispatch constants.TOGGLE_TODO, id:   id
  clearTodos:      -> @dispatch constants.CLEAR_TODOS

# Creation of a Flux instance

stores = { TodoStore: new TodoStore }
flux = new Fluxxor.Flux(stores, actions)

# Logging upon the "dispatch" event

  onClearTodos: ->
    todos = @todos
    Object.keys(todos).forEach (key) ->
      delete todos[key] if todos[key].complete
    @emit 'change'

  getState: ->
    todos: @todos

  _nextTodoId: ->
    @todoId += 1

# Semantic actions

