Last active
September 28, 2016 07:02
-
-
Save KoryNunn/41298d8704ceb827ff6c69b95bfc8863 to your computer and use it in GitHub Desktop.
Righto version of https://derickbailey.com/2016/09/27/ending-the-nested-tree-of-doom-with-chained-promises/
This file contains hidden or 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
| // Assumes <Thing>.get is a normal err-back API. | |
| var json = righto.from(xmltojsonhttpclient.get()), | |
| transform = righto(SearchModel.get, json), | |
| mappedData = righto(SearchController.get, transform), | |
| contractData = righto(ContractModel.get, mappedData), | |
| mappedContractData = righto(ContractController.get, contractData); | |
| mappedContractData(function(error, result){ | |
| // Do what you want. | |
| }); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm assuming the .get() calls in the original return promises, and I'm thinking there may be a case that can be added to righto that handles tasks that return promises or rightos, but that will be based on future requirements.
EDIT: Meh, I added it: https://gist.github.com/KoryNunn/999c5578ef2144986d3bcb4f2ae246d0