Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Elixir
  3. async_with

async_with

MITElixirv0.3.0

An asynchronous version of Elixir's 'with' that resolves dependency graphs and executes clauses for optimal performance.

Visit WebsiteGitHubGitHub
156 stars4 forks0 contributors

What is async_with?

AsyncWith is an Elixir library that provides an asynchronous version of the `with` special form. It enables concurrent execution of multiple pattern-matching clauses by automatically resolving dependencies between them and spawning tasks for parallel processing. This solves the problem of sequential execution in standard `with` blocks, allowing developers to write more performant concurrent code while maintaining Elixir's familiar pattern-matching semantics.

Target Audience

Elixir developers who use `with` expressions extensively and want to improve performance through concurrency, particularly those building applications with independent operations that can be executed in parallel.

Value Proposition

Developers choose AsyncWith because it seamlessly extends Elixir's beloved `with` syntax with automatic concurrency, requiring minimal code changes while providing significant performance gains through intelligent dependency analysis and task parallelization.

Overview

The asynchronous version of Elixir's "with", resolving the dependency graph and executing the clauses in the most performant way possible!

Use Cases

Best For

  • Parallelizing independent data-fetching operations in Elixir applications
  • Improving performance of complex `with` blocks with multiple independent clauses
  • Writing concurrent Elixir code while maintaining pattern-matching semantics
  • Automatically resolving execution dependencies in concurrent workflows
  • Reducing latency in pipelines with multiple independent steps
  • Learning concurrent programming patterns in functional Elixir code

Not Ideal For

  • Projects with strict sequential dependencies not expressed in variable bindings, like updating shared state in agents
  • Simple workflows with few or no independent clauses where task spawning overhead negates benefits
  • Teams prioritizing minimal external dependencies who prefer core Elixir constructs over libraries
  • Applications with tight resource constraints where concurrent task management could strain memory or CPU

Pros & Cons

Pros

Automatic Dependency Resolution

Analyzes variable dependencies between clauses to spawn tasks optimally, maximizing parallelism without manual ordering.

Seamless Syntax Integration

Simply add 'async' to 'with' with minimal code changes, preserving Elixir's familiar pattern-matching semantics.

Efficient Resource Management

Early termination shuts down running tasks if a clause fails, preventing unnecessary work and saving resources.

Full Pattern Matching Support

Supports guards and else blocks just like standard with, maintaining expressive error handling in concurrent contexts.

Cons

Race Condition Risks

Order-dependent clauses without explicit variable dependencies can lead to unpredictable behavior, as noted in the README with agent updates.

Formatter Configuration Overhead

Requires adjustments to .formatter.exs or manual setup to avoid parentheses in async with calls, adding initial complexity.

Limited for Trivial Cases

For simple with blocks with few dependencies, the overhead of task spawning may not justify performance gains.

External Dependency Lock-in

Adds reliance on a third-party library for core functionality, which could introduce breaking changes or compatibility issues over time.

Frequently Asked Questions

Quick Stats

Stars156
Forks4
Contributors0
Open Issues0
Last commit3 years ago
CreatedSince 2017

Tags

#macro#functional-programming#elixir#async-programming#async#pattern-matching#task-parallelism#dependency-graph#concurrency#performance

Built With

E
Elixir

Links & Resources

Website

Included in

Elixir13.1k
Auto-fetched 18 hours ago

Related Projects

erlang-historyerlang-history

Hacks to add shell history to Erlang's shell

Stars495
Forks30
Last commit8 years ago
retryretry

Simple Elixir macros for linear retry, exponential backoff and wait with composable delays

Stars456
Forks35
Last commit1 year ago
quarkquark

Common combinators for Elixir

Stars322
Forks15
Last commit4 years ago
erlware_commonserlware_commons

Erlware Commons is an Erlware project focused on all aspects of reusable Erlang components.

Stars225
Forks102
Last commit25 days ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub