A hot-swappable field: yieldable for reads, with control methods on the field
itself (yield* field reads; field.set(v) / field.reset / field.changes
control).
export interface interface SwappableField<A>A hot-swappable field: yieldable for reads, with control methods on the field
itself (yield* field reads; field.set(v) / field.reset / field.changes
control).
SwappableField<function (type parameter) A in SwappableField<A>A> extends interface ConfigField<A>A yieldable config field. yield* field reads its underlying Config
through the ambient provider. Read-only on its own;
SwappableField
adds the control methods — so swappability is a structural distinction, not a
stored marker flag.
ConfigField<function (type parameter) A in SwappableField<A>A> {
/** Swap the value (raw/encoded form); validated through the field's Config. */
readonly SwappableField<A>.set: (value: string) => Effect.Effect<void, Config.ConfigError, DynamicConfigStore>Swap the value (raw/encoded form); validated through the field's Config.
set: (
value: stringvalue: string,
) => import EffectEffect.interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<void, import ConfigConfig.class ConfigErrorclass ConfigError {
_tag: 'ConfigError';
name: string;
cause: SourceError | Schema.SchemaError;
message: string;
toString: () => string;
}
Represents the error type produced when config loading or validation fails.
When to use
Use when you need to inspect config loading or validation failures.
Details
Wraps either:
- A
SourceError — the provider could not read data (I/O failure).
- A
SchemaError — the data was found but did not match the schema
(wrong type, out of range, missing key, etc.).
ConfigError, class DynamicConfigStoreclass DynamicConfigStore {
key: Identifier;
Service: {
setRaw: (entries: ReadonlyArray<readonly [string, string]>) => Effect.Effect<void>;
unsetRaw: (keys: ReadonlyArray<string>) => Effect.Effect<void>;
changedKeys: Stream.Stream<ReadonlyArray<string>>;
allowed: ReadonlyMap<string, Config.Config<unknown>>;
};
}
Shared override store. Provided by
layer
; written by a swappable
field's .set / .reset (and
setByKey
), and read (as a
ConfigProvider) by every Config.
DynamicConfigStore>;
/** Drop the override; revert to env/default. */
readonly SwappableField<A>.reset: Effect.Effect<void, never, DynamicConfigStore>(property) SwappableField<A>.reset: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
Drop the override; revert to env/default.
reset: import EffectEffect.interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<void, never, class DynamicConfigStoreclass DynamicConfigStore {
key: Identifier;
Service: {
setRaw: (entries: ReadonlyArray<readonly [string, string]>) => Effect.Effect<void>;
unsetRaw: (keys: ReadonlyArray<string>) => Effect.Effect<void>;
changedKeys: Stream.Stream<ReadonlyArray<string>>;
allowed: ReadonlyMap<string, Config.Config<unknown>>;
};
}
Shared override store. Provided by
layer
; written by a swappable
field's .set / .reset (and
setByKey
), and read (as a
ConfigProvider) by every Config.
DynamicConfigStore>;
/** Stream of this field's changed env keys on swap/reset. */
readonly SwappableField<A>.changes: Stream.Stream<ReadonlyArray<string>, never, DynamicConfigStore>(property) SwappableField<A>.changes: {
channel: Channel.Channel<Arr.NonEmptyReadonlyArray<A>, E, void, unknown, unknown, unknown, R>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
Stream of this field's changed env keys on swap/reset.
changes: import StreamStream.interface Stream<out A, out E = never, out R = never>A Stream<A, E, R> describes a program that can emit many A values, fail
with E, and require R.
Details
Streams are pull-based with backpressure and emit chunks to amortize effect
evaluation. They support monadic composition and error handling similar to
Effect, adapted for multiple values.
Example (Creating and consuming streams)
import { Console, Effect, Stream } from "effect"
const program = Effect.gen(function*() {
yield* Stream.make(1, 2, 3).pipe(
Stream.map((n) => n * 2),
Stream.runForEach((n) => Console.log(n))
)
})
Effect.runPromise(program)
// Output:
// 2
// 4
// 6
Stream<
interface ReadonlyArray<T>ReadonlyArray<string>,
never,
class DynamicConfigStoreclass DynamicConfigStore {
key: Identifier;
Service: {
setRaw: (entries: ReadonlyArray<readonly [string, string]>) => Effect.Effect<void>;
unsetRaw: (keys: ReadonlyArray<string>) => Effect.Effect<void>;
changedKeys: Stream.Stream<ReadonlyArray<string>>;
allowed: ReadonlyMap<string, Config.Config<unknown>>;
};
}
Shared override store. Provided by
layer
; written by a swappable
field's .set / .reset (and
setByKey
), and read (as a
ConfigProvider) by every Config.
DynamicConfigStore
>;
}