Layer.Layer<Socket.WebSocketConstructor, never, never>Provides a Socket.WebSocketConstructor backed explicitly by the ws
package.
export const const layerWebSocketConstructorWS: Layer.Layer<Socket.WebSocketConstructor>const layerWebSocketConstructorWS: {
build: (memoMap: MemoMap, scope: Scope.Scope) => Effect<Context.Context<WebSocketConstructor>, never, never>;
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; <…;
}
Provides a Socket.WebSocketConstructor backed explicitly by the ws
package.
layerWebSocketConstructorWS: 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<
import SocketSocket.class WebSocketConstructorclass WebSocketConstructor {
Service: Service;
key: Identifier;
}
Context service for constructing WebSocket instances from a URL and
optional protocols.
WebSocketConstructor
> = import LayerLayer.const succeed: {
<I, S>(service: Context.Key<I, S>): (
resource: S
) => Layer<I>
<I, S>(
service: Context.Key<I, S>,
resource: Types.NoInfer<S>
): Layer<I>
}
Constructs a layer that provides a single service from an already available
value.
When to use
Use when you need a Layer that provides a service from an already
constructed implementation without effectful acquisition.
Example (Creating a layer from a service implementation)
import { Context, Effect, Layer } from "effect"
class Database extends Context.Service<Database, {
readonly query: (sql: string) => Effect.Effect<string>
}>()("Database") {}
const DatabaseLive = Layer.succeed(Database, {
query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Query result: ${sql}`))
})
succeed(import SocketSocket.class WebSocketConstructorclass WebSocketConstructor {
key: Identifier;
of: (this: void, self: (url: string, protocols?: string | Array<string> | undefined) => globalThis.WebSocket) => (url: string, protocols?: string | Array<string> | undefined) => globalThis.WebSocket;
context: (self: (url: string, protocols?: string | Array<string> | undefined) => globalThis.WebSocket) => Context<Socket.WebSocketConstructor>;
use: (f: (service: (url: string, protocols?: string | Array<string> | undefined) => globalThis.WebSocket) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Socket.WebSocketConstructor | R>;
useSync: (f: (service: (url: string, protocols?: string | Array<string> | undefined) => globalThis.WebSocket) => A) => Effect.Effect<A, never, Socket.WebSocketConstructor>;
Identifier: Identifier;
Service: Shape;
stack: string | undefined;
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;
}
Context service for constructing WebSocket instances from a URL and
optional protocols.
WebSocketConstructor)(
(url: stringurl, protocols: string | string[] | undefinedprotocols) => new import WSWS.WebSocket(url: stringurl, protocols: string | string[] | undefinedprotocols) as unknown as module globalThisglobalThis.WebSocket
)