RpcGroup.ts overview
Since v1.0.0
Exports Grouped by Category
groups
HandlersContext (type alias)
Signature
type HandlersContext<Rpcs, Handlers> = keyof Handlers extends infer K
? K extends keyof Handlers & string
? [Rpc.IsStream<Rpcs, K>] extends [true]
? Handlers[K] extends (
...args: any
) =>
| Stream.Stream<infer _A, infer _E, infer _R>
| Rpc.Fork<Stream.Stream<infer _A, infer _E, infer _R>>
| Effect.Effect<ReadonlyMailbox<infer _A, infer _E>, infer _EX, infer _R>
| Rpc.Fork<Effect.Effect<ReadonlyMailbox<infer _A, infer _E>, infer _EX, infer _R>>
? Exclude<Rpc.ExcludeProvides<_R, Rpcs, K>, Scope>
: never
: Handlers[K] extends (
...args: any
) => Effect.Effect<infer _A, infer _E, infer _R> | Rpc.Fork<Effect.Effect<infer _A, infer _E, infer _R>>
? Rpc.ExcludeProvides<_R, Rpcs, K>
: never
: never
: never
Since v1.0.0
HandlersFrom (type alias)
Signature
type HandlersFrom<Rpc> = {
readonly [Current in Rpc as Current["_tag"]]: (
payload: Rpc.Payload<Current>,
headers: Headers
) => ResultFrom<Current> | Rpc.Fork<ResultFrom<Current>>
}
Since v1.0.0
ResultFrom (type alias)
Signature
type ResultFrom<Rpc> =
Rpc extends Rpc.Rpc<infer _Tag, infer _Payload, infer _Success, infer _Error, infer _Middleware>
? [_Success] extends [RpcSchema.Stream<infer _SA, infer _SE>]
?
| Stream.Stream<_SA["Type"], _SE["Type"] | _Error["Type"], any>
| Effect.Effect<
ReadonlyMailbox<_SA["Type"], _SE["Type"] | _Error["Type"]>,
_SE["Type"] | Schema.Schema.Type<_Error>,
any
>
: Effect.Effect<_Success["Type"], _Error["Type"], any>
: never
Since v1.0.0
RpcGroup (interface)
Signature
export interface RpcGroup<in out Rpcs extends Rpc.Any> extends Pipeable {
new (_: never): {}
readonly [TypeId]: TypeId
readonly requests: ReadonlyMap<string, Rpcs>
readonly annotations: Context.Context<never>
/**
* Add one or more procedures to the group.
*/
add<const Rpcs2 extends ReadonlyArray<Rpc.Any>>(...rpcs: Rpcs2): RpcGroup<Rpcs | Rpcs2[number]>
/**
* Merge this group with another group.
*/
merge<Rpcs2 extends Rpc.Any>(that: RpcGroup<Rpcs2>): RpcGroup<Rpcs | Rpcs2>
/**
* Add middleware to all the procedures added to the group until this point.
*/
middleware<M extends RpcMiddleware.TagClassAny>(middleware: M): RpcGroup<Rpc.AddMiddleware<Rpcs, M>>
/**
* Implement the handlers for the procedures in this group, returning a
* context object.
*/
toHandlersContext<Handlers extends HandlersFrom<Rpcs>, EX = never, RX = never>(
build: Handlers | Effect.Effect<Handlers, EX, RX>
): Effect.Effect<Context.Context<Rpc.ToHandler<Rpcs>>, EX, RX | HandlersContext<Rpcs, Handlers>>
/**
* Implement the handlers for the procedures in this group.
*/
toLayer<Handlers extends HandlersFrom<Rpcs>, EX = never, RX = never>(
build: Handlers | Effect.Effect<Handlers, EX, RX>
): Layer.Layer<Rpc.ToHandler<Rpcs>, EX, Exclude<RX, Scope> | HandlersContext<Rpcs, Handlers>>
/**
* Annotate the group with a value.
*/
annotate<I, S>(tag: Context.Tag<I, S>, value: S): RpcGroup<Rpcs>
/**
* Annotate the Rpc's above this point with a value.
*/
annotateRpcs<I, S>(tag: Context.Tag<I, S>, value: S): RpcGroup<Rpcs>
/**
* Annotate the group with a context object.
*/
annotateContext<S>(context: Context.Context<S>): RpcGroup<Rpcs>
/**
* Annotate the Rpc's above this point with a context object.
*/
annotateRpcsContext<S>(context: Context.Context<S>): RpcGroup<Rpcs>
}
Since v1.0.0
Rpcs (type alias)
Signature
type Rpcs<Group> = Group extends RpcGroup<infer R> ? R : never
Since v1.0.0
make
Signature
declare const make: <const Rpcs extends ReadonlyArray<Rpc.Any>>(...rpcs: Rpcs) => RpcGroup<Rpcs[number]>
Since v1.0.0
type ids
TypeId
Signature
declare const TypeId: unique symbol
Since v1.0.0
TypeId (type alias)
Signature
type TypeId = typeof TypeId
Since v1.0.0