Posts tagged with async

Leveraging Promises and HTTP Pooling in Laravel

cosmastech.com

Laravel 8 first introduced HTTP request pooling, thanks to a contribution from Andrea Marco Sartori. This allows developers to write code which will execute any number of HTTP requests concurrently. Under the hood, this is made possible thanks to the async request functionality of Guzzle and cURL’s multi handler functionality.

Read more [cosmastech.com]

Join 9,500+ smart developers

Every month I share what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.

No spam. Unsubscribe anytime. You can also follow me on X.

Introducing React Suspense

At the Zeit conference React core member Andrew Clark showed off an upcoming React feature named Suspense. It can automatically pause the render process of a component if it hasn't got all its data. In can be used to avoid things like spinner showing up too quickly.

Async rendering in React gives us a powerful new set of primitives for addressing longstanding problems in UI development. I'll discuss React's vision for how async rendering can improve data fetching, code delivery, prefetching, view transitions, and more.

Read more

Beyond React 16

Today at the JSConf in Iceland, React core developer Dan Abramov demonstrated some very cool features that will soon land in React.

We’ve built a generic way to ensure that high-priority updates don’t get blocked by a low-priority update. We call this time slicing. If my device is fast enough, it feels almost like it’s synchronous; if my device is slow, the app still feels responsive. We’ve also built a generic way for components to suspend rendering while they load async data. We call this feature suspense. You can pause any state update until the data is ready, and you can add async loading to any component deep in the tree without plumbing all the props and state through your app and hoisting the logic.

https://reactjs.org/blog/2018/03/01/sneak-peek-beyond-react-16.html

Read more

spatie/async will be released soon

My colleague Brent is currently creating a new package called spatie/async. This one will let you easily do some asynchronous parallel processing in PHP. In a new post on his blog Brent explains why we are creating the package and compares it to a few other solutions out there.

If you're into parallel PHP, you probably heard of Amp and ReactPHP. Our package aims not to compete with those two, as it only solves one tiny aspect of parallelism in PHP. We did however use both the packages to run some benchmarks against. Let's take a look at the results.

https://www.stitcher.io/blog/asynchronous-php

Read more

An async map function original

by Freek Van der Herten – 3 minute read

Laravel has an excellent Collection class that has many useful operations. The class is also macroable. This means that you can add function to it at runtime by calling macro on it and passing a name and a closure. In our projects we tend to code up the same macro's over and over again. That's why…

Read more

Asynchronous stack traces: why await beats .then()

On his blog Mathias Bynens explains the differences under the hood between async/await and vanilla promises.

The fundamental difference between await and vanilla promises is that await X() suspends execution of the current function, while promise.then(X) continues execution of the current function after adding the X call to the callback chain. In the context of stack traces, this difference is pretty significant. ... Enable JavaScript engines to handle stack traces in a more performant and memory-efficient manner by following these recommendations:
  • Prefer async/await over desugared promises.
  • Use babel-preset-env to avoid transpiling async/await unnecessarily. ...

https://mathiasbynens.be/notes/async-stack-traces

Read more