Skip to content

Instantly share code, notes, and snippets.

@KinoAR
Created August 14, 2017 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KinoAR/75f81f64f74fec064da2b8dee82a5359 to your computer and use it in GitHub Desktop.
Save KinoAR/75f81f64f74fec064da2b8dee82a5359 to your computer and use it in GitHub Desktop.
A short example of callback hell.
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