Created
August 14, 2017 14:42
-
-
Save KinoAR/75f81f64f74fec064da2b8dee82a5359 to your computer and use it in GitHub Desktop.
A short example of callback hell.
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
getCat((data) => { | |
const catEmbed = new RichEmbed({ title: 'Meow' }) | |
catEmbed.setImage(data.file); | |
message.channel.send("Nyaa ~ :cat: ", { embed: catEmbed }) | |
.then(message => console.log(`Sent message: ${message.content}`)) | |
.catch(console.error); | |
/* ES5 Function */ | |
getCat(function (data) { | |
/* Cat data 2 operations... */ | |
getCat((data) => { | |
/* Cat data 3 operations... */ | |
getCat((data) => { | |
/* Cat data 4 operations... | |
* Okay, too many callbacks now. | |
* Oh look a triangle. | |
*/ | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment