Urgent.News

650+ sources. One page. See who else covered it.

Editions

Tech

What do you think of LazyPromise as a lightweight alternative to Effect?

LazyPromise is a lightweight alternative to Effect, offering a promise-like API while taking care to maintain key features from Observable. It emits synchronously instead of in a microtask, supports typed errors, and has a dependency injection system.

One key difference between LazyPromise and native Promise is the cancellation mechanism. While native Promise is eager, LazyPromise supports cancellation via AbortController API. Additionally, LazyPromise avoids the "Zalgo" guarantee that native Promise provides, ensuring that microtasks are not mandatory.

Like Observable, LazyPromise runs its constructor callback each time someone subscribes, unlike native Promise which executes only once. LazyPromise also shares similarities with a single-shot Observable, which complements Signals without falling into the "Diamond Problem."

In terms of API, LazyPromise mirrors native Promise, including features like cancelling upstream LazyPromise derived from operators, supporting AbortController API, and providing methods to convert between LazyPromise and Promise. LazyPromise also introduces the concept of boxed errors, allowing for type checking of errors without the need for an extra channel like native Promise.

Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at github.com →

More in Tech

Understand Pointers, simple and easy with Go

Lidar com ponteiros pela primeira vez assusta quem vem de linguagens como JavaScript, Python ou Java, onde a gestão de memória é automática Mas a ideia é mais simples do que parece.

  • Pointers are variables holding memory addresses of other variables, not their values.
  • In Go, pointers are declared using the & operator, e.g., &x for a variable x.
Hackers target DHQ social media account

Hackers target DHQ social media account

The Defence Headquarters (DHQ) confirms its official X account was compromised in an attempted cyberattack. Learn about the security measures taken. Read More: https://punchng.com/hackers-target-dhq-social-media-account/

More from Saturday 15 August →