Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
}
}
);
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
}
}
);
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
}
import Dispatcher from 'flux/lib/Dispatcher';
import $ajax from '../utils/service';
import { httpLog } from '../utils/logging';
Dispatcher.prototype.$ajax = $ajax;
Dispatcher.prototype.loadEndpoint = function (endpoint, data = {}) {
if (this.$ajax instanceof Function !== true) throw new Error("$ajax handler not initialized");
// console.log("Ajax request in Dispatcher: " + endpoint);
return this.$ajax({
endpoint,
data,
success: (res) => {
httpLog(`AJAX Response to endpoint: ${endpoint}`);
this.dispatch({ type: endpoint, res });
},
error: (err) => {
httpLog(`AJAX ERROR Response to endpoint: ${endpoint}`);
this.dispatch({ type: `error-${endpoint}`, err });
},
});
import Dispatcher from 'flux/lib/Dispatcher';
import $ajax from '../utils/service';
import { httpLog } from '../utils/logging';
Dispatcher.prototype.$ajax = $ajax;
Dispatcher.prototype.loadEndpoint = function (endpoint, data = {}) {
if (this.$ajax instanceof Function !== true) throw new Error("$ajax handler not initialized");
// console.log("Ajax request in Dispatcher: " + endpoint);
return this.$ajax({
endpoint,
data,
success: (res) => {
httpLog(`AJAX Response to endpoint: ${endpoint}`);
this.dispatch({ type: endpoint, res });
},
error: (err) => {
httpLog(`AJAX ERROR Response to endpoint: ${endpoint}`);
this.dispatch({ type: `error-${endpoint}`, err });
constructor(props: GigaProps) {
super(props);
this.dispatcher = new Dispatcher();
this.store = GigaGrid.createStore(props, this.dispatcher);
this.state = this.store.getState();
// do not call setState again, this is the only place! otherwise you are violating the principles of Flux
// not that would be wrong but it would break the 1 way data flow and make keeping track of mutation difficult
this.store.addListener(() => {
this.setState(this.store.getState());
});
}
_createDispatcher() {
// No need to dispose dispatcher, GC will eat it.
this._dispatcher = new Dispatcher;
Map(this.actionsAndStores).forEach((array, feature) => {
const {store} = Flux.findActionsAndStores(array);
if (!store) return;
this._dispatcher.register(this._onDispatch.bind(this, feature, store));
});
}