Scope bridge API carried by Store.Storage.
export interface StorageApi {
readonly StorageApi.at: <Input extends StoreSpec | StoreContractValue>(scopeKey: string, input: Input) => Effect.Effect<StoreHandleOf<Input>, StoreScopeNotRegistered>at: <function (type parameter) Input in <Input extends StoreSpec | StoreContractValue>(scopeKey: string, input: Input): Effect.Effect<StoreHandleOf<Input>, StoreScopeNotRegistered>Input extends type StoreSpec = {
readonly [x: string]: StoreSpecEntry;
}
StoreSpec | type StoreContractValue<Shapes extends StoreShapes = Readonly<Record<string, StoreShapeInput>>, Custom extends Readonly<Record<string, unknown>> = Readonly<Record<never, never>>> = StoreContractDef<Shapes, Custom> & PipeableStoreContractValue>(
scopeKey: stringscopeKey: string,
input: Input extends StoreSpec | StoreContractValueinput: function (type parameter) Input in <Input extends StoreSpec | StoreContractValue>(scopeKey: string, input: Input): Effect.Effect<StoreHandleOf<Input>, StoreScopeNotRegistered>Input,
) => 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<type StoreHandleOf<S> = S extends StoreContractValue ? Simplify<Simplify<StoreShapeHandleTree<S["shapes"]>> & Simplify<{ readonly [K in CustomHandleKeys<S>]: CustomMethodOf<S, K>; }>> : S extends Readonly<Record<string, StoreSpecEntry>> ? Simplify<{ -readonly [K in keyof S as S[K] extends StoreSpecEntry ? K : never]: S[K] extends StoreAppendEntry<infer A> ? (payload: A) => Effect.Effect<void, StoreWriteError> : S[K] extends StoreQueryEntry<...> ? (payload: P) => Effect.Effect<A> : never; }> : neverStoreHandleOf<function (type parameter) Input in <Input extends StoreSpec | StoreContractValue>(scopeKey: string, input: Input): Effect.Effect<StoreHandleOf<Input>, StoreScopeNotRegistered>Input>, class StoreScopeNotRegisteredclass StoreScopeNotRegistered {
name: string;
message: string;
stack: string;
cause: unknown;
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;
_tag: Tag;
key: string;
}
StoreScopeNotRegistered>;
readonly StorageApi.changes: (scopeKey: string) => Effect.Effect<Stream.Stream<StoreChangeEvent, StoreJournalDecodeError>, StoreScopeNotRegistered, Scope>changes: (
scopeKey: stringscopeKey: 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<
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<class StoreChangeEventclass StoreChangeEvent {
scopeKey: string;
method: string;
payload: unknown;
_tag: Tag;
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; <…;
}
Emitted on each append when
Store.changes
is subscribed.
StoreChangeEvent, class StoreJournalDecodeErrorclass StoreJournalDecodeError {
name: string;
message: string;
stack: string;
cause: unknown;
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;
_tag: Tag;
detail: string | undefined;
}
StoreJournalDecodeError>,
class StoreScopeNotRegisteredclass StoreScopeNotRegistered {
name: string;
message: string;
stack: string;
cause: unknown;
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;
_tag: Tag;
key: string;
}
StoreScopeNotRegistered,
Scope
>;
}