effect-cycle-ws
v0.1.0
Published
WebSocket driver for effect-cycle
Readme
effect-cycle-ws
WebSocket driver for effect-cycle.
Install
pnpm add effect-cycle-ws effect-cycle-core effectUsage
import { Effect, Stream } from "effect"
import { WSSink, WSSource } from "effect-cycle-ws"
const app = Effect.gen(function* () {
const ws = yield* WSSource
const send = yield* WSSink
yield* Stream.runForEach(ws.messages, (msg) =>
Effect.log(`recv: ${msg.data}`),
)
yield* send.send(Stream.make("hello"))
})WSDriverLive opens the socket lazily on first subscription and tears it down with the surrounding Scope. See validatedMessageEffect for Schema-decoded inbound messages.
See the main README and DESIGN.md for the full design.
License
MIT © Josh Burgess
