Created
December 23, 2015 19:49
-
-
Save whichsteveyp/120d58d0e8c1b594936e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// const AppDispatcher =, etc... | |
module.exports = { | |
getCommentsForRequestWithBind(requestID, rowBusinessKey) { | |
superagent.get(`/api/${requestID}/comments`, this.updateRequestCommentsInRow.bind(this, requestID, rowBusinessKey), someGlobalErrorAction); | |
}, | |
getCommentsForRequestLambda(requestID, rowBusinessKey) { | |
superagent.get(`/api/${requestID}/comments`, comments => this.updatedRequestCommentsInRow(requestID, rowBusinessKey, comments), someGlobalErrorAction); | |
}, | |
updateRequestCommentsInRow(requestID, rowBusinessKey, comments) { | |
// current data structure limits require the business key in order to look up the request and attach comments to it | |
/* | |
{ | |
businessKey: { | |
requests: [ | |
{ requestID, comments } | |
] | |
} | |
} | |
*/ | |
AppDispatcher.dispatch({ // grabs a request in a given row, updates the comments, other magic, etc | |
rowBusinessKey, | |
requestID, | |
comments, | |
type: UPDATE_REQUEST_COMMENTS | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Each method contains
requestID
, which, w/ the use of bind, indicates an alternate approach. To me, it's clear thatrequestID
should be passed into a wrapper function. Also, I'm unsure why athis
is required instead of goingthis
-less.