PromiseLogic.and()

Core Logic GateAND Logic - Succeeds when all Promises succeed

The PromiseLogic.and() method implements AND logic gate semantics, succeeding when all input Promises succeed. It returns a PromiseWithTimer instance which wraps the native Promise and provides additional functionality.

Syntax

javascript
 PromiseLogic.and(iterable)

Parameters

ParameterTypeDescription
iterableIterable<Promise<T>>An iterable collection of Promise objects

Return Value

Returns a PromiseWithTimer that resolves to an array of all input Promise successful values.

PromiseWithTimer<T[]>

Behavior

Success Condition

When all input Promises resolve successfully, returns a PromiseWithTimer that resolves to an array of all successful values.

Failure Condition

When any input Promise is rejected, the PromiseWithTimer is immediately rejected with the first rejection reason.

Error Types

AND_ERRORThrown when any Promise in the input fails

Examples

Basic Usage

AND Logic Example - Succeeds when all Promises succeed

JAVASCRIPT
Loading...

Error Handling

AND Logic Failure Example - Any Promise failure causes overall failure

JAVASCRIPT
Loading...

Timeout Control

Add timeout control with maxTimer method

JAVASCRIPT
Loading...

Real Application

Load multiple API data in parallel with timeout

JAVASCRIPT
Loading...

Important Notes

  • AND logic behaves exactly like standard Promise.all()
  • Any Promise failure immediately causes overall failure (short-circuit behavior)
  • Returns PromiseWithTimer which supports maxTimer() for timeout control
  • maxTimer can only detect timeout, cannot cancel the Promise operation itself
  • Suitable for scenarios where all operations must succeed to continue
  • For scenarios where partial success is acceptable, consider using PromiseLogic.or()