(path: string): <Self>(node: NodeKey<Self>) => Layer.Layer<Self>
<Self>(
node: NodeKey<Self> & {
readonly path?: string
readonly endpoints?: Endpoints
}
): Layer.Layer<Self, UnaddressedNode>Wire a node over IpcSocket — Unix-domain socket RPC (protocolIpc), connect
pinned to kind: "IpcSocket". Dual: MyNode.pipe(Hyperlink.connectIpc) uses the node's own path;
MyNode.pipe(Hyperlink.connectIpc(path)) overrides it.
export const const connectIpc: {
(path: string): <Self>(
node: NodeKey<Self>
) => Layer.Layer<Self>
<Self>(
node: NodeKey<Self> & {
readonly path?: string
readonly endpoints?: Endpoints
}
): Layer.Layer<Self, UnaddressedNode>
}
Wire a node over IpcSocket — Unix-domain socket RPC (
protocolIpc
),
connect
pinned to kind: "IpcSocket". Dual: MyNode.pipe(Hyperlink.connectIpc) uses the node's own path;
MyNode.pipe(Hyperlink.connectIpc(path)) overrides it.
connectIpc: {
(path: stringpath: 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 path?: string;
readonly endpoints?: Endpoints;
}): Layer.Layer<Self, UnaddressedNode>
Self>(
node: anynode: import NodeKeyNodeKey<function (type parameter) Self in <Self>(node: NodeKey<Self> & {
readonly path?: string;
readonly endpoints?: Endpoints;
}): Layer.Layer<Self, UnaddressedNode>
Self> & { readonly path?: string | undefinedpath?: 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 path?: string;
readonly endpoints?: Endpoints;
}): Layer.Layer<Self, UnaddressedNode>
Self, import UnaddressedNodeUnaddressedNode>;
} = import FnFn.const dual: <(...args: Array<any>) => any, (node: NodeKey<unknown> & {
readonly path?: string;
readonly endpoints?: Endpoints;
}, path?: string) => Layer.Layer<unknown, UnaddressedNode>>(isDataFirst: (args: IArguments) => boolean, body: (node: NodeKey<unknown> & {
readonly path?: string;
readonly endpoints?: Endpoints;
}, path?: string) => Layer.Layer<unknown, UnaddressedNode>) => ((...args: Array<any>) => any) & ((node: NodeKey<unknown> & {
readonly path?: string;
readonly endpoints?: Endpoints;
}, path?: string) => Layer.Layer<unknown, UnaddressedNode>) (+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 path?: string | undefinedpath?: string; readonly endpoints?: anyendpoints?: import EndpointsEndpoints },
path: string | undefinedpath?: string,
// Prefer the node's OWN IpcSocket endpoint over the primary `path` (multi-protocol parity).
): 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 UnaddressedNodeUnaddressedNode> => {
const const sock: anysock = path: string | undefinedpath ?? node: anynode.endpoints?.IpcSocket?.path ?? node: anynode.path;
if (const sock: anysock === var undefinedundefined) {
return import unaddressedLayerunaddressedLayer(node: anynode.key);
}
return import connectLayerconnectLayer(node: anynode, import HyperlinkHyperlink.protocolIpc(const sock: anysock));
},
);