Skip to main content

Overview

The combine and combineWithAllErrors static methods allow you to combine multiple ResultAsync instances into a single ResultAsync.

Signatures

ResultAsync.combine

ResultAsync.combineWithAllErrors

Usage

Parallel async operations

Heterogeneous operations

Short-circuit behavior

Collect all errors

Real-world examples

Form validation

Parallel API calls

Key characteristics

combine

  • Short-circuits: Stops at first error
  • Efficient: May not execute all operations
  • Single error: Returns first error encountered

combineWithAllErrors

  • Exhaustive: Executes all operations
  • Complete: Collects all errors
  • Error array: Returns array of all errors
Use combine for independent operations where one failure should stop everything. Use combineWithAllErrors for validations where you want to show all errors to the user.

Result.combine

Synchronous version

Combining Results Guide

Detailed usage patterns