Terms used precisely. Every contributor and every AI agent agrees on these definitions.
This library sits at the intersection of three concepts that share the word "effect." Distinguishing them is foundational.
| Term | Meaning here | Lineage |
|---|---|---|
| Vue effect | A reactive computation that re-runs when its dependencies change (watchEffect, internal effects in computed/watch) |
Vue 3 reactivity system |
| Side-effect | An observable interaction with the outside world (network, IO, mutation) | General programming term |
| Effect (capitalized) | A Effect.Effect<A, E, R> value from Effect-TS — a typed, lazily-described program that, when run, may produce a value of type A, fail with E, or require services R |
Effect-TS / ZIO / Cats Effect |
When this library says "effect" without qualification, context determines which:
- "Effect-TS effect" or "Effect" = the typed program-as-value
- "Vue effect" = the reactive computation
- "side-effect" = the observable interaction
A reactive container. Concretely: Ref<A | undefined> (for async sources) or Ref<A> (for plain values), produced by createAtom. Tied to a Vue effect scope; cleaned up on scope dispose.
NOT an opaque "atom type" like in
@effect-atom/atom-react. In effect-vue, an atom IS a Vue ref.
The argument to createAtom. One of: a plain value, an Effect.Effect<A, E>, or a Stream.Stream<A, E>.
A ManagedRuntime.ManagedRuntime<R, never> produced by provideAtomRuntime(layer). Runs Effects within the scope of its provided Layer. Atoms in descendant components automatically use it. Inherited via Vue's provide/inject.
A typed, composable description of services. From Effect-TS: Layer.Layer<R, E, In> — produces services of type R, may fail with E, requires services In to construct. Effect-vue accepts these directly via provideAtomRuntime.
A lightweight concurrent computation. Spawned when an atom is created from an Effect or Stream. Owns the work of executing the source. Lifecycle is bounded by the surrounding Vue effect scope.
Effect.Scope in Effect-TS — bounds resource allocation/cleanup. Vue.EffectScope in Vue — bounds reactive effect ownership. effect-vue treats them as aligned: every Fiber lives within an Effect Scope, which is itself within a Vue EffectScope.
The conceptual mapping point where a Vue primitive meets an Effect-TS primitive. The three bridges in effect-vue:
- Stream → Ref bridge —
Streamemissions update aRefviaStream.runForEach - Layer → Vue.provide bridge —
provideAtomRuntimeputs aManagedRuntimeinto Vue's injection tree - Scope → onScopeDispose bridge —
onScopeDisposecallsFiber.interrupton the atom's fiber
A Vue 3 composition API function (useX, createX, provideX, injectX). All effect-vue exports are composables.
For createAtom (slice 1, value/Effect/Stream sources):
| State | Meaning | ref.value |
|---|---|---|
| pending | Source spawned, no value yet (only async sources) | undefined |
| resolved | Source produced (most recent) value | the emitted value |
| disposed | Owning effectScope ended; fiber interrupted | observation from outside scope is undefined behavior |
For useAsyncAtom (slice 2, exposes typed errors):
| State | Meaning | data |
error |
pending |
|---|---|---|---|---|
| idle | Effect not yet started (lazy mode) | undefined |
undefined |
false |
| pending | Effect running | undefined |
undefined |
true |
| resolved | Effect succeeded | A |
undefined |
false |
| failed | Effect failed with typed error | undefined |
E |
false |
A component's setup() runs. Its effectScope is created. Atoms created in setup() live within this scope.
The owning effectScope ends (component unmount, manual scope cleanup). All registered onScopeDispose handlers fire. Effect-vue's handler interrupts the atom's fiber.
This library composes three abstraction layers, each historically called "effect":
Vue reactivity ← "effect" as in watchEffect (reactive computations)
↑
Pinia Colada ← "effect" as in side-effects (queries / mutations)
↑
Effect-TS ← "Effect" as in algebraic effect (typed program)
The pinia-colada-effect package is the bridge between layers 2 and 3. The @effect-vue/core package is the bridge between layers 1 and 3.