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 } });
player.on('event', function (event) { if (event.state === 'stopped') list.destroy() })