Primitives / foldkit-primitives/net
sse
function · packages/primitives/src/net/sse.ts:94
function sse<const Name extends string>(config: {
readonly name: Name
readonly createSource?: ((url: string) => SourceHandle) | undefined
}): Bundle.Bundle<
Name,
{ readonly url: string },
{
readonly url: string
readonly status: 'closed' | 'open' | 'connecting'
readonly lastError: Option.Option<string>
},
| { readonly _tag: 'Opened' }
| { readonly _tag: 'Closed' }
| { readonly _tag: 'Failed'; readonly message: string }
| { readonly _tag: 'Received'; readonly data: string }
| { readonly _tag: 'Connecting' },
never,
ManagedResource.ManagedResourceService<'sse'>,
ManagedResource.ManagedResourceService<'sse'>,
NoView,
{
source: ManagedResource.Entry<
{
readonly url: string
readonly status: 'closed' | 'open' | 'connecting'
readonly lastError: Option.Option<string>
},
| { readonly _tag: 'Opened' }
| { readonly _tag: 'Closed' }
| { readonly _tag: 'Failed'; readonly message: string }
| { readonly _tag: 'Received'; readonly data: string }
| { readonly _tag: 'Connecting' },
Option.Option<string>,
AcquiredSource,
ManagedResource.ManagedResourceService<'sse'>,
() => { readonly _tag: 'Connecting' }
>
},
{},
undefined
>Server-sent events as a bundle: connection lifecycle in the Model, the event stream through one Managed Resource. One-directional, so there is no send: the server speaks, the Model listens. The browser reconnects dropped streams itself; a Failed only records the error.