Created
September 7, 2011 22:32
-
-
Save brandonbloom/1202000 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
queue = [] | |
providerA = (args...) -> | |
console.log args | |
providerB = (args...) -> | |
alert args | |
doRequest = (args...) -> | |
queue.push args | |
chooseProvider = (callback) -> | |
timeout = null | |
setProvider = (provider) -> | |
clearTimeout timeout | |
doRequest = provider | |
for args in queue | |
doRequest args... | |
setDefaultProvider = -> | |
setProvider providerA | |
timeout = setTimeout(setDefaultProvider, 1000) | |
callDiscoveryService | |
success: (response) -> | |
setProvider f(response) | |
error: -> | |
setDefaultProvider |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment