Today we will talk about Promises 🤝. But first, let's understand what a promise is. A promise has 3 states: pending, fulfilled, and rejected. Here is the breakdown
When a promise is returned, it could be any of the above values.
Let's review our weekly snack 👇
What if there are several promises that we want to resolve? Well, then we might have heard of `Promise.all`.
Promise.all will allow us to invoke all promises in the form of an array and will return an array of resolved values.
But wait, hold on. There is a catch here. If one of the promises is rejected, then all of a sudden, the entire Promise chain is rejected. This is not usually what we want, as we still want our app to function as expected and don't want it to stop working if one thing doesn't work.
So how can we solve this problem? 🤔
Promise.allSettled will also return the resolved as well as rejected values of the promises unlike Promise.all. In case, one promise gets rejected, we will still get the resolved values of other promises. This way, our app will continue to function.
Introducing Svelte 1.0: A new version of Svelte is out. It's a framework used to build apps with server-side rendering but does things differently. Svelte is built on top of Vite.
SWR 2.0 by Vercel: SWR 2.0 is out. SWR is a popular React data-fetching library that enables components to fetch, cache, and mutate data. SWR 2.0 makes it better by providing ease of use, additional hooks, and more optimizations to make it easier to fetch data.
Vite 4.0 is out: Vite 4.0 is finally out and has exciting changes. We already saw Nuxt and Astro built on top of Vite.
Have a wonderful day!