Sse
Constructors
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
Signature
declare function makeParser(onParse: (event: AnyEvent) => void, options?: DecodeOptions): Parser;Errors
EventTooLarge
Added in v1.0.0
Source
Signature
declare class EventTooLarge extends YieldableError<this> & {
readonly _tag: "EventTooLarge";
} & Readonly<{
readonly maxEventSize: number;
}> {
constructor(args: {
readonly maxEventSize: number;
});
message: string;
}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
Signature
type AnyEvent = Event | Retry;DecodeOptions interface
Added in v1.0.0
Source
Signature
interface DecodeOptions {
readonly maxEventSize?: number;
}Signature
interface Encoder {
write(event: AnyEvent): string;
}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;
}Signature
interface Parser {
feed(chunk: string): SseError | undefined;
reset(): void;
}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;
Create a SSE parser.
Adapted from https://github.com/rexxars/eventsource-parser under MIT license.
feedreturns anSseErrorif the pending event exceedsmaxEventSize.