i am trying to understand JavaScript over here and then i read this:

"Because this function returns a Promise and we return that promise to the .then, we can then chain a .then to the end of that."

..deep breaths.....

  • 1
    Or not 🤔
  • 7
    Promise chains!

    Promises are definitly difficult to get your head around at first, but once you do (sometimes it takes a few times) they click and make a lot of sense. They also absolutely make your life easier.

    Stick with it.

    and honestly, ignore the complicated things for now. Start with the basics, and use them until you sort of get it. then keep going and adding little bits on until it all just clicks. That will save you a lot of hassle and confusion.
  • 1
    I finally got my head around promises, then went away for a week. They made no sense again when I returned!

    Observables do the same thing to me
  • 2
    So you have experienced the callback hell that existed before promises?
    They ain't that difficult to wrap your head around, maybe you should try async/await it will be more familiar to you, the syntax is nice.
  • 1
    Converting between promises, callbacks, streams, events, async etc is good fun
  • 0
    This was me a few months ago. If you ditch promise chains and work with async/await it makes it easier I think. I also did all my promise learning on typescript not pure JS so that may have colored my view
  • 1
    Promises are not the issue, they are present in most other languages (Futures in jvm languages), the problem is no consensus on what to use so libraries might use promises, might need callbacks or might just return async values.
  • 0
    Interestingly I find promises much harder than observables. Maybe this is because I have most of my js experience in Angular.
Add Comment