Understanding JavaScript Promise Mechanics and Practical Patterns
The Promise constructor initializes an object that tracks the lifecycle of an asynchronous operation, transitioning from a pending state to either fulfilled or rejected. It accepts an executor function containing two control parameters: a resolution function to mark success and a rejection function to signal failure.
Because the executor execut ...
Posted on Sun, 04 Oct 2026 16:30:09 +0000 by Orkan
Implementing Asynchronous Operations in OpenHarmony NAPI with Callbacks and Promises
This article builds upon the foundation of porting third-party libraries to OpenHarmony NAPI. We'll modify the hellonapi.cpp and index.ets files to explore asynchronous operations using Promises and Callbacks within the NAPI framework. This guide includes three examples: a Callback-based asynchronous interface, a Promise-based asynchronous inte ...
Posted on Sun, 20 Sep 2026 16:19:52 +0000 by scliburn
Executing Multiple Promises Concurrently with Promise.all
The Promise.all() static method accepts an iterable collection of Promise objects and returns a new Promise. This returned Promise resolves when all input Promises have successfully fulfilled, providing an array containing their resolved values in the same order. If any of the input Promises reject, the resulting Promise immediately rejects wit ...
Posted on Wed, 09 Sep 2026 16:37:27 +0000 by SapAuthor
HarmonyOS NEXT Promise Await Exception Handling Without Cluttered Try-Catch Blocks
Async/await operasions throw errors when the underlying Promise rejects, halting eexcution of subsequent code. For example:
async function simulateRequest() {
console.log('Request initiated');
const response = await new Promise<string>((resolve, reject) => {
setTimeout(() => reject('Data fetch timeout'), 1200);
});
conso ...
Posted on Mon, 31 Aug 2026 16:30:53 +0000 by hkothari
Modern JavaScript Reactive Systems, Async Patterns, and Browser APIs
Proxy and Reflect: Building Reactive Systems
Modern JavaScript frameworks like Vue 3 leverage Proxy and Reflect to implement reactivity more efficiently than the older Object.defineProperty approach. While defineProperty can only observe existing properties and requires manual intervention for additions or deletions, Proxy intercepts fundamenta ...
Posted on Tue, 25 Aug 2026 16:47:28 +0000 by alsal
Understanding Promise Internals: A Deep Dive into Promise/A+ Implementation
Constructor
The Promise constructor accepts an executor function that receives two arguments: resolve and reject. This is where the core initialization logic resides.
class SimplePromise {
constructor(executor) {
this.status = PENDING;
this.onFulfilledCallbacks = [];
this.onRejectedCallbacks = [];
executor(
...
Posted on Fri, 08 May 2026 04:06:07 +0000 by jmosterb