Skip to content
Search

Effect

lastmod 2024-06-17created 2021-09-252 edits

A library that helps you build robust apps with TypeScript

Features

  • "The missing Standard Library for TypeScript"
  • Designed to make complex synchronous/asynchronous programs easy to build
  • Makes code more Composable, Reusable, and Testable
  • Maximum Type-Safety (including error handling)
  • Provides a variety of libraries
  • Provides clustering & workflows (alpha version)
  • Broad compatibility
    • Node, Deno, Bun, Cloudflare Workers, Chrome
    • React, Solid.JS , Vite, Next.JS, Tauri
  • Key features
    • Concurrency (Concurrency): a Fiber-based concurrency model makes it possible to build highly scalable, ultra-low-latency applications
    • Composability (Composability): build maintainable, readable, and flexible software using small, reusable components
    • Resource Safety (Resource Safety): safely manage the acquisition and release of resources even when the program fails
    • Type Safety (Type Safety): focuses on type inference and type safety, making full use of the TypeScript type system
    • Error Handling (Error Handling): handle errors in a structured, reliable way using built-in error handling features
    • Asynchronicity (Asynchronicity): write code that looks the same whether it is synchronous or asynchronous
    • Observability (Observability): easily debug and monitor program execution with full tracing

Why Effect?

  • Programming is hard
  • When building libraries and apps, we use many tools to manage complexity
  • Effect offers a new way of thinking about TypeScript programming
  • The tools in the Effect ecosystem let you build better applications and libraries
  • This helps you better understand the TypeScript language and type system and make programs more reliable and easier to maintain.

The Effect pattern

  • Typical TypeScript code assumes a function will either succeed or throw an exception
    • e.g., a divide function throws an exception when dividing by 0
  • You can't tell from the types alone that this function can throw an exception
  • This problem grows when a codebase has hundreds or thousands of functions
  • Exception handling is easy to forget and hard to manage
  • The TypeScript compiler is the first line of defense against bugs, domain errors, and general complexity

See also

Favorite site

author Zer0 sitemap