Пример #1
0
Dispatcher.register(function(action) {
  switch(action.actionType) {
    case Constants.CREATE:
      store.create(action.contact);
      store.emitChange();
      break;

    case Constants.DESTROY:
      store.destroy(action.email);
      store.emitChange();
      break;

    case Constants.RECEIVE_ALL:
      _contacts = action.contacts;
      store.emitChange();
      break;

    case Constants.RECEIVE_CREATED:
      // Remove existing copy
      store.destroy(action.contact.email);
      // Add new
      store.create(action.contact);
      // emit change event to notify listeners
      store.emitChange();
      break;

    default:
      // no op
  }
});
Пример #2
0
        todoService.getTodos().done(function(data){

            _.map(data, function(x){

                todoList.push({
                    "id" : x.id,
                    "name" : x.name,
                    "isComplete": x.isComplete
                })
            });

            initialLoadToDo = true;

            TodoStore.emitChange();
        })
Пример #3
0
TodoStore.update = function(content) {
    console.log("TodoStore update");
    console.log(todoList);
    // var found = _.find(this.todoList, function(x){return x.id == content.id;});
    
    // console.log(content);
    // console.log(this.todoList);

    // for (var name in found)
    //     found[name] = content[name];
    // console.log(this.todoList);

     todoService.updateTodo(content).done(function(data) {
     });

    TodoStore.emitChange();
};
Пример #4
0
 .then(function(data) {
     console.log('todo added. returned to TodoStore');
     todoList.push(content);  
     TodoStore.emitChange();
 });
Пример #5
0
 .then(function(data) {
     todoList = _.filter(todoList, function(x){return x.id != content.id;});
     TodoStore.emitChange();
 });