Type Alias: EffectFn() {#type-alias-effectfn}

EffectFn = <R>(opts) => Promise<R>

Function signature for the ergonomic effect API in ProcessContext. Accepts a named { key, run } object instead of positional arguments. When key is a string[], it is canonically encoded to avoid collision bugs.

Type Parameters {#type-parameters}

R {#r}

R

Parameters {#parameters}

opts {#opts}

key {#opts-key}

string | string[]

run {#opts-run}

() => Promise<R> | R

Returns {#returns}

Promise<R>

Example {#example}

const charge = await ctx.effect({
  key: 'stripe-charge',
  run: () => stripe.charges.create({ amount: 1000 }),
})

// Array keys for dynamic effect deduplication
const result = await ctx.effect({
  key: ['send-email', userId],
  run: () => sendEmail(userId),
})