Created
June 14, 2016 15:46
-
-
Save sansarun/d3d40f529a7aa33f2c288050d1470a2c to your computer and use it in GitHub Desktop.
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
function getSensors(callback) { | |
var sensorList = [1, 2, 3]; | |
setTimeout(function(){ | |
callback(sensorList); | |
}, 3000); | |
} | |
function getSensorData(id, callback) { | |
setTimeout(function(){ | |
callback("Sensor data for id:" + id); | |
}, 3000); | |
} | |
getSensors(function(sensorList) { | |
console.log("sensor list = ", sensorList); | |
sensorList.forEach(function(sensor, index) { | |
getSensorData(sensor, function(data) { | |
console.log(data); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment