Last active
October 19, 2018 18:41
-
-
Save nem035/45cfd820a1e4c0292578842dbb7a11c3 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
// when performing an async operation that requires a callback | |
// we have to immediately provide that callback | |
// and would need to maintain or pass around a reference to | |
// the callback in our codebase if we wanted to handle the | |
// response in a different place from where we started the async | |
// process. | |
httpGet(function callback() { | |
// we have to provide this callback immediately | |
// when starting this operation and cannot do | |
// it at a later point. | |
}) | |
// best we can do to split the async op from our reaction to | |
// it is to extract the callback as a standalone function. | |
// Even so, this is just positional separation, not temporal | |
// or functional. We still maintain a direct reference to our | |
// async operation => tight coupling | |
httpGet(callback) | |
// ... somewhere else | |
function callback() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment