src/js/stores/ChartMetadataStore.js
function registeredCallback(payload) {
	var action = payload.action;
	var data;

	switch(action.eventName) {
		/*
		* New chart model is received. Respond by first waiting for
		* `ChartProptiesStore`
		*/
		case "receive-model":
			Dispatcher.waitFor([ChartPropertiesStore.dispatchToken]);
			_metadata = action.model.metadata;
			data = ChartPropertiesStore.get("data");
			_metadata.title = defaultTitle(data);
			ChartMetadataStore.emitChange();
			break;

		/* Metadata alone is being updated */
		case "update-metadata":
			_metadata[action.key] = action.value;
			// if title is edited, set dirty to true and dont generate default anymore
			// TODO: we don't need to do this every time
			if (action.key == "title") {
				titleDirty = true;
			}
			ChartMetadataStore.emitChange();
			break;

		case "update-and-reparse":
			if (!titleDirty) {
				data = ChartPropertiesStore.get("data");
				_metadata.title = defaultTitle(data);
				ChartMetadataStore.emitChange();
			}
			break;

		case "update-data-input":
			if (!titleDirty) {
				data = ChartPropertiesStore.get("data");
				_metadata.title = defaultTitle(data);
				ChartMetadataStore.emitChange();
			}
			break;

		default:
			// do nothing
	}

	return true;

}
function registeredCallback(payload) {
	var action = payload.action;
	var data;

	switch(action.eventName) {
		/*
		* New chart model is received. Respond by first waiting for
		* `ChartProptiesStore`
		*/
		case "receive-model":
			Dispatcher.waitFor([ChartPropertiesStore.dispatchToken]);
			_metadata = action.model.metadata;
			data = ChartPropertiesStore.get("data");
			_metadata.title = defaultTitle(data);
			ChartMetadataStore.emitChange();
			break;

		/* Metadata alone is being updated */
		case "update-metadata":
			_metadata[action.key] = action.value;
			// if title is edited, set dirty to true and dont generate default anymore
			// TODO: we don't need to do this every time
			if (action.key == "title") {
				titleDirty = true;
			}
			ChartMetadataStore.emitChange();
			break;

		case "update-and-reparse":
			if (!titleDirty) {
				data = ChartPropertiesStore.get("data");
				_metadata.title = defaultTitle(data);
				ChartMetadataStore.emitChange();
			}
			break;

		case "update-data-input":
			if (!titleDirty) {
				data = ChartPropertiesStore.get("data");
				_metadata.title = defaultTitle(data);
				ChartMetadataStore.emitChange();
			}
			break;

		default:
			// do nothing
	}

	return true;

}
/* Respond to actions coming from the dispatcher