Created
September 30, 2014 22:14
-
-
Save obscuren/3779dc005c981d9977e7 to your computer and use it in GitHub Desktop.
promises vs regular async
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
eth.getKey(function(key) { | |
eth.getStorageAt("someaddr", "somelocation", function(address) { | |
eth.compile("thiscode", function(code) { | |
eth.transact({to: address, from: key, gas: 10000, gasPrice: eth.gasPrice, data:[code]}, function(tx){ | |
console.log(tx) | |
}) | |
}) | |
}) | |
}) | |
// VS | |
eth.transact({ | |
to: eth.storageAt("a", "b"), | |
from: eth.key, | |
gas: 1000, | |
gasPrice: eth.gasPrice, | |
data: eth.compile("code"), | |
}). | |
then(function(tx) { | |
console.log(tx); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your second example with a callback.
There are many better ways of demonstrating how promises are awesome, but in your example promises are actually not needed.