Skip to content
Effect Days 2026 Get your ticket

Sse

15 exports Added in v1.0.0 Source

Constructors

encoder

Added in v1.0.0 Source

Signature

declare const encoder: Encoder

makeChannel

Added in v1.0.0 Source

Signature

declare function makeChannel<IE, Done>(options?: DecodeOptions & {
readonly bufferSize?: number;
}): Channel<Chunk<Event>, Chunk<string>, IE, IE, void, Done>

makeParser

Added in v1.0.0 Source

Create a SSE parser.

Adapted from https://github.com/rexxars/eventsource-parser under MIT license. feed returns an SseError if the pending event exceeds maxEventSize.

Signature

declare function makeParser(onParse: (event: AnyEvent) => void, options?: DecodeOptions): Parser

Errors

Signature

declare class EventTooLarge extends YieldableError<this> & {
readonly _tag: "EventTooLarge";
} & Readonly<{
readonly maxEventSize: number;
}> {
constructor(args: {
readonly maxEventSize: number;
});
message: string;
}

SseError

Added in v1.0.0 Source

Signature

declare class SseError extends YieldableError<this> & {
readonly _tag: "SseError";
} & Readonly<{
readonly cause: EventTooLarge;
}> {
constructor(args: {
readonly cause: EventTooLarge;
});
readonly "@effect/experimental/Sse/SseError": "@effect/experimental/Sse/SseError";
message: string;
}

SseErrorReason type

Added in v1.0.0 Source

Signature

type SseErrorReason = EventTooLarge

Models

AnyEvent type

Added in v1.0.0 Source

Signature

type AnyEvent = Event | Retry

DecodeOptions interface

Added in v1.0.0 Source

Signature

interface DecodeOptions {
readonly maxEventSize?: number;
}

Encoder interface

Added in v1.0.0 Source

Signature

interface Encoder {
write(event: AnyEvent): string;
}

Event interface

Added in v1.0.0 Source

Signature

interface Event {
readonly _tag: "Event";
readonly data: string;
readonly event: string;
readonly id: string | undefined;
}

EventEncoded interface

Added in v1.0.0 Source

Signature

interface EventEncoded {
readonly data: string;
readonly event: string;
readonly id: string | undefined;
}

Parser interface

Added in v1.0.0 Source

Signature

interface Parser {
feed(chunk: string): SseError | undefined;
reset(): void;
}

Retry

Added in v1.0.0 Source

Signature

declare class Retry extends Readonly<{
readonly duration: Duration;
readonly lastEventId: string | undefined;
}> & {
readonly _tag: "Retry";
} & Pipeable {
constructor(args: {
readonly duration: Duration;
readonly lastEventId: string | undefined;
});
readonly [RetryTypeId]: typeof RetryTypeId;
static is(u: unknown): u is Retry;
}

Type Ids

RetryTypeId

Added in v1.0.0 Source

Signature

declare const RetryTypeId: unique symbol

RetryTypeId type

Added in v1.0.0 Source

Signature

type RetryTypeId = typeof RetryTypeId