export class 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>>;
};
}
DynamicConfigStore extends import ContextContext.const Service: <DynamicConfigStore, {
readonly setRaw: (entries: ReadonlyArray<readonly [string, string]>) => Effect.Effect<void>;
readonly unsetRaw: (keys: ReadonlyArray<string>) => Effect.Effect<void>;
readonly changedKeys: Stream.Stream<ReadonlyArray<string>>;
readonly allowed: ReadonlyMap<string, Config.Config<unknown>>;
}>() => <Identifier, E, R, Args>(id: Identifier, options?: {
readonly make: ((...args: Args) => Effect.Effect<{
readonly setRaw: (entries: ReadonlyArray<readonly [string, string]>) => Effect.Effect<void>;
readonly unsetRaw: (keys: ReadonlyArray<string>) => Effect.Effect<void>;
readonly changedKeys: Stream.Stream<ReadonlyArray<string>>;
readonly allowed: ReadonlyMap<string, Config.Config<unknown>>;
}, E, R>) | Effect.Effect<...> | undefined;
} | undefined) => Context.ServiceClass<...> & ([...] extends [...] ? unknown : {
...;
}) (+2 overloads)
Creates a Context service key.
When to use
Use when you need to define a context service key for a dependency that must
be provided by the surrounding context.
Details
Call Context.Service("Key") for a function-style key, or use the two-stage
form Context.Service<Self, Shape>()("Key") for class-style service
declarations. The returned key can be yielded as an Effect and passed to
Context.make, Context.add, and the Context getter functions.
Gotchas
The string key is the runtime identity of the service. Reusing the same key
string for unrelated services makes them occupy the same slot in a
Context.
Example (Creating service keys)
import { Context } from "effect"
// Create a simple service
const Database = Context.Service<{
query: (sql: string) => string
}>("Database")
// Create a service class
class Config extends Context.Service<Config, {
port: number
}>()("Config") {}
// Use the services to create contexts
const db = Context.make(Database, {
query: (sql) => `Result: ${sql}`
})
const config = Context.make(Config, { port: 8080 })
Service<
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>>;
};
}
DynamicConfigStore,
{
readonly setRaw: (
entries: ReadonlyArray<
readonly [string, string]
>
) => Effect.Effect<void>
setRaw: (
entries: readonly (readonly [string, string])[]entries: interface ReadonlyArray<T>ReadonlyArray<readonly [string, 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>;
readonly unsetRaw: (
keys: ReadonlyArray<string>
) => Effect.Effect<void>
unsetRaw: (keys: readonly string[]keys: interface ReadonlyArray<T>ReadonlyArray<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>;
readonly changedKeys: Stream.Stream<
readonly string[],
never,
never
>
(property) changedKeys: {
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; <…;
}
changedKeys: 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>>;
/** This provision's {@link setByKey} allowlist: the process-wide {@link SwappableRegistry}
* (from {@link globalSwappable}) plus any {@link swappable} fields in the config passed to
* {@link layer}. */
readonly allowed: ReadonlyMap<
string,
Config.Config<unknown>
>
allowed: interface ReadonlyMap<K, V>ReadonlyMap<string, import ConfigConfig.interface Config<out T>A recipe for extracting a typed value T from a ConfigProvider.
When to use
Use to describe typed configuration that can be parsed from a provider or
yielded inside Effect.gen.
Details
Key members:
parse(provider, pathPrefix?) – runs the config against a specific provider.
The optional path prefix is the logical scope accumulated from outer
Config.nested calls.
- Yieldable – can be yielded inside
Effect.gen, which automatically
resolves the current ConfigProvider from the context.
- Pipeable – supports
.pipe(Config.map(...)) etc.
Config<unknown>>;
}
>()("hyperlink-ts/DynamicConfig/DynamicConfigStore") {}
Source src/DynamicConfig.ts:20914 lines
Referenced by 4 symbols