Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function(action) {
switch (action.actionType) {
case actionsConstants.SEARCH_START:
SearchStore.emit(actionsConstants.SEARCH_START);
break;
case actionsConstants.SEARCH_RESULTS:
searchResults = action.results;
searchError = null;
SearchStore.emit(actionsConstants.SEARCH_RESULTS);
break;
case actionsConstants.SEARCH_ERROR:
searchResults = null;
searchError = action.error;
SearchStore.emit(actionsConstants.SEARCH_ERROR);
break;
default:
// no op
function(action) {
switch (action.actionType) {
case actionsConstants.SEARCH_START:
SearchStore.emit(actionsConstants.SEARCH_START);
break;
case actionsConstants.SEARCH_RESULTS:
searchResults = action.results;
searchError = null;
SearchStore.emit(actionsConstants.SEARCH_RESULTS);
break;
case actionsConstants.SEARCH_ERROR:
searchResults = null;
searchError = action.error;
SearchStore.emit(actionsConstants.SEARCH_ERROR);
break;
default:
// no op
}
search: function(query) {
if (!isSearching) {
isSearching = true;
dispatcher.dispatch({
actionType: actionsConstants.SEARCH_START
});
api.search(query)
.then(
function(result) {
dispatcher.dispatch({
actionType: actionsConstants.SEARCH_RESULTS,
results: result
});
isSearching = false;
},
function(error) {
dispatcher.dispatch({
actionType: actionsConstants.SEARCH_ERROR,
error: error
});
isSearching = false;