JavaScript

Callback hell

Në shqip përdoret i njëjti emër.

ShpjegimiSQ

Callback hell është kur callback-et futen brenda callback-eve aq shumë herë sa kodi bëhet një „piramidë“ e vështirë për t'u lexuar. Promise-t dhe async/await u krijuan pikërisht për ta zgjidhur këtë.

EnglishEN

Callback hell is when callbacks get nested inside callbacks so many times that the code turns into a hard-to-read “pyramid”. Promises and async/await were created precisely to fix this.

Si ta mendosh

Si udhëzimet: „Kur të vish, merre çelësin te fqinji, e kur ta marrësh, hape derën, e kur ta hapësh, ndize dritën, e kur…“ — në fund s'kupton më asgjë.

Lexoje në anglisht

Like directions: “When you arrive, get the key from the neighbour, and when you have it, open the door, and when it's open, turn on the light, and when…” — by the end you're lost.

Shembull kodijavascript

merrPerdoruesin((p) => {
  merrPorosite(p, (porosite) => {
    merrDetajet(porosite[0], (d) => console.log(d));  // piramida rritet…
  });
});

Terma të lidhur