(url: string): <Self>(node: NodeKey<Self>) => Layer.Layer<Self>
<Self>(
node: NodeKey<Self> & {
readonly url?: string
readonly endpoints?: Endpoints
}
): Layer.Layer<Self>Wire a node over http — Effect's layerProtocolHttp transport, connect pinned to
kind: "Http". Dual: MyNode.pipe(Hyperlink.connectHttp) uses the node's own url (or "/rpc");
MyNode.pipe(Hyperlink.connectHttp(url)) overrides it.
export const const connectHttp: {
(url: string): <Self>(
node: NodeKey<Self>
) => Layer.Layer<Self>
<Self>(
node: NodeKey<Self> & {
readonly url?: string
readonly endpoints?: Endpoints
}
): Layer.Layer<Self>
}
Wire a node over http — Effect's layerProtocolHttp transport,
connect
pinned to
kind: "Http". Dual: MyNode.pipe(Hyperlink.connectHttp) uses the node's own url (or "/rpc");
MyNode.pipe(Hyperlink.connectHttp(url)) overrides it.
connectHttp: {
// data-last first, node form last — so the bare pipe (`node.pipe(connectHttp)`) resolves to the node
// overload (TS picks the last for a bare value); `connectHttp(url)` still matches the string overload.
(url: stringurl: string): <function (type parameter) Self in <Self>(node: NodeKey<Self>): Layer.Layer<Self>Self>(node: NodeKey<Self>node: import NodeKeyNodeKey<function (type parameter) Self in <Self>(node: NodeKey<Self>): Layer.Layer<Self>Self>) => import LayerLayer.interface Layer<in ROut, out E = never, out RIn = never>A Layer describes how to build one or more services for dependency injection.
When to use
Use to model construction of application services for dependency injection,
especially when services have dependencies, can fail during construction, or
need scoped setup and release.
Details
A Layer<ROut, E, RIn> represents ROut as the services this layer
provides, E as the possible errors during layer construction, and RIn as
the services this layer requires as dependencies.
Layer<function (type parameter) Self in <Self>(node: NodeKey<Self>): Layer.Layer<Self>Self>;
<function (type parameter) Self in <Self>(node: NodeKey<Self> & {
readonly url?: string;
readonly endpoints?: Endpoints;
}): Layer.Layer<Self>
Self>(
node: anynode: import NodeKeyNodeKey<function (type parameter) Self in <Self>(node: NodeKey<Self> & {
readonly url?: string;
readonly endpoints?: Endpoints;
}): Layer.Layer<Self>
Self> & { readonly url?: string | undefinedurl?: string; readonly endpoints?: anyendpoints?: import EndpointsEndpoints },
): import LayerLayer.interface Layer<in ROut, out E = never, out RIn = never>A Layer describes how to build one or more services for dependency injection.
When to use
Use to model construction of application services for dependency injection,
especially when services have dependencies, can fail during construction, or
need scoped setup and release.
Details
A Layer<ROut, E, RIn> represents ROut as the services this layer
provides, E as the possible errors during layer construction, and RIn as
the services this layer requires as dependencies.
Layer<function (type parameter) Self in <Self>(node: NodeKey<Self> & {
readonly url?: string;
readonly endpoints?: Endpoints;
}): Layer.Layer<Self>
Self>;
} = import FnFn.const dual: <(...args: Array<any>) => any, (node: NodeKey<unknown> & {
readonly url?: string;
readonly endpoints?: Endpoints;
}, url?: string) => Layer.Layer<unknown>>(isDataFirst: (args: IArguments) => boolean, body: (node: NodeKey<unknown> & {
readonly url?: string;
readonly endpoints?: Endpoints;
}, url?: string) => Layer.Layer<unknown>) => ((...args: Array<any>) => any) & ((node: NodeKey<unknown> & {
readonly url?: string;
readonly endpoints?: Endpoints;
}, url?: string) => Layer.Layer<unknown>) (+1 overload)
Creates a function that can be called in data-first style or data-last
(pipe-friendly) style.
When to use
Use to expose one implementation through both direct and pipe-friendly
call styles.
Details
Pass either the arity of the uncurried function or a predicate that decides
whether the current call is data-first. Arity is the common case. Use a
predicate when optional arguments make arity ambiguous.
Example (Selecting data-first or data-last style by arity)
import { Function, pipe } from "effect"
const sum = Function.dual<
(that: number) => (self: number) => number,
(self: number, that: number) => number
>(2, (self, that) => self + that)
console.log(sum(2, 3)) // 5
console.log(pipe(2, sum(3))) // 5
Example (Defining overloads with call signatures)
import { Function, pipe } from "effect"
const sum: {
(that: number): (self: number) => number
(self: number, that: number): number
} = Function.dual(2, (self: number, that: number): number => self + that)
console.log(sum(2, 3)) // 5
console.log(pipe(2, sum(3))) // 5
Example (Selecting data-first or data-last style with a predicate)
import { Function, pipe } from "effect"
const sum = Function.dual<
(that: number) => (self: number) => number,
(self: number, that: number) => number
>(
(args) => args.length === 2,
(self, that) => self + that
)
console.log(sum(2, 3)) // 5
console.log(pipe(2, sum(3))) // 5
dual(
(args: IArgumentsargs: IArguments) => typeof args: IArgumentsargs[0] !== "string",
(
node: anynode: import NodeKeyNodeKey<unknown> & { readonly url?: string | undefinedurl?: string; readonly endpoints?: anyendpoints?: import EndpointsEndpoints },
url: string | undefinedurl?: string,
// Prefer the node's OWN Http endpoint over the primary `url` — a multi-protocol `{ http, ws }` node
// has a WebSocket primary-or-http primary but its Http endpoint is the right target for `connectHttp`.
): import LayerLayer.interface Layer<in ROut, out E = never, out RIn = never>A Layer describes how to build one or more services for dependency injection.
When to use
Use to model construction of application services for dependency injection,
especially when services have dependencies, can fail during construction, or
need scoped setup and release.
Details
A Layer<ROut, E, RIn> represents ROut as the services this layer
provides, E as the possible errors during layer construction, and RIn as
the services this layer requires as dependencies.
Layer<unknown> =>
import connectLayerconnectLayer(node: anynode, import HyperlinkHyperlink.protocolHttp(url: string | undefinedurl ?? node: anynode.endpoints?.Http?.url ?? node: anynode.url ?? "/rpc")),
);