Asynchronous JS (Ajax, callbacks, promises)

While struggling with Node js stuff I thought that it was the time for understanding Callbacks and asynchronicity in JS. (Honestly I should have done it with Twitch tv, Pomodoro and al). Here’s a wonderful playlist by the Net Ninja - for those who don’t know it yet. (otherwise, sorry for the repeat or Moderators’ intervention welcome :slight_smile: ).

So clean up your code, you spaghetti makers !

Each video is max 13 minutes long.
Full playlist here.


I just finished watching the 3rd,4th and 5th links you posted. I am using Promises with my React project and these videos just made it much clearer for me to understand how these promises work. Thanks!
I strongly recommend for anyone who’s using async requests.

1 Like

You should try redux-observable and rx.js instead of plain promises.

Promises pretty much do what I need to. I am using fetch which returns a promise and I don’t have any problems with it.
What are the advantages using these promises?

Well, first things first, they are not promises, they are observables which is a completely different thing. rx.js is a common reactive extension provider for javascript :bulb:
redux-observable is a library that uses rx.js as a transformer of redux events.

Observable is a stream of events, which has many similarities with plain collections. It’s easier to operate with observables using pure functions and functional reactive programming approach. Observables have map, forEach, filter functions and JS arrays have them too…

There are reactive extensions for mostly every existing popular programming language. They are providing a vast set of operators, mastering those do require a lot of effort and practice, like functional programming. But advantages are too huge …

For instance, average vanilla JS WebSocket connection handling implementation would take like 300 lines of code (LoC) and using redux-observable it would take up to ~16 LoC.

Every major frontend project, both mobile, desktop and web ones, use reactive extensions to keep things simple and maintainable.

With plain promises you can’t synchronize states and prevent side-effects appropriately, which will cause a lot of strange bugs due to undetermined nature :fire: . You SHOULD use redux instead :fire_engine: .

You can watch Jay Phelps video to get a bit into redux-observable.

Tutorial wise there’s
and redux-observable docs
which should be more than enough.

1 Like