Skip to content

Instantly share code, notes, and snippets.

@nxnzesrc
Last active December 5, 2017 16:20
Show Gist options
  • Select an option

  • Save nxnzesrc/eba60b1dbd4678b8a0fb27d15c4c46e6 to your computer and use it in GitHub Desktop.

Select an option

Save nxnzesrc/eba60b1dbd4678b8a0fb27d15c4c46e6 to your computer and use it in GitHub Desktop.
Commenting on comments (what comments)
import { isString, isObject } from 'lodash';
function updateAnswer(updateCommand, typeKeys) {
// If either of `updateCommand` or `typeKeys`
// is null or defined, then we can stop here and just return
if (!updateCommand || !typeKeys) {
return;
}
// If `typeKeys` is a string
if (isString(typeKeys)) {
return {
type: typeKeys,
updateCommand
};
}
// If `typeKeys` is an object
if (isObject(typeKeys)) {
return (dispatch, getState) => {
dispatch({ type: typeKeys.update, updateCommand });
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment