Ich möchte mit Promises arbeiten, habe aber eine Callback-API in einem Format wie:
1. DOM load oder andere einmalige Ereignisse:
window.onload; // auf callback setzen
...
window.onload = function() {
};
2. Einfacher Callback:
function request(onChangeHandler) {
...
}
request(function() {
// Änderung erfolgte
...
});
3. Node-Style-Callback ("nodeback"):
function getStuff(dat, callback) {
...
}
getStuff("dataParam", function(err, data) {
...
})
4. Eine ganze Bibliothek mit Node-Style-Callbacks:
API;
API.one(function(err, data) {
API.two(function(err, data2) {
API.three(function(err, data3) {
...
});
});
});