Last active
December 3, 2015 08:02
-
-
Save vasanthk/dc4cb612b089085d7b74 to your computer and use it in GitHub Desktop.
For understanding callback hell better... and inversion of control.
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
| var cbFn = function() { | |
| console.log('Done') | |
| } | |
| // Run Async API call | |
| completeAsyncCheckout(data, cbFn); | |
| cbFn = function() { | |
| // Guessing it prints 'Finished' since it has reference. | |
| console.log('Finished'); | |
| } | |
| // In this scenario: | |
| // Have this qn because from your talk - 'Syncing Async' you mentioned that due to inversion of control they could potentially call the cbFn multiple times. | |
| // Wondering how that could happen? | |
| // The callback is called once the request completes right? Or is there a way a callback can be triggered multiple times once a request is complete? | |
| // What controls how many times the success callback will be called? |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@getify Gotcha.. Thanks a lot. You're my JS hero!