Yoga.Om.Strom.WebStream
- Package
- purescript-yoga-om-strom
- Repository
- rowtype-yoga/purescript-yoga-om-strom
#ReadableStream Source
data ReadableStream t0#WritableStream Source
data WritableStream t0#TransformStream Source
data TransformStream t0 t1#toReadableStream Source
toReadableStream :: forall a ctx err. ctx -> Strom ctx err a -> Effect (ReadableStream a)Convert a Strom to a ReadableStream. Elements are enqueued individually. Requires ctx to run the Om effects. Errors become stream errors with preserved error information. Supports cancellation — when the consumer cancels the ReadableStream, the internal fiber is killed.
#fromReadableStream Source
fromReadableStream :: forall a ctx err. ReadableStream a -> Strom ctx err aConvert a ReadableStream to a Strom using batched reads. Each pull reads up to 1000 elements from the underlying reader in a tight JS loop, producing properly-sized chunks that match Strom's batch model. The reader is released when the stream ends.
Note: if the consumer stops pulling early (e.g. via takeStrom), the
reader lock is not released until GC. Use useReadableStream for
guaranteed cleanup on abandonment.
#fromReadableStreamWith Source
fromReadableStreamWith :: forall a ctx err. { chunkSize :: Int } -> ReadableStream a -> Strom ctx err aConvert a ReadableStream to a Strom with a configurable chunk (batch) size. Larger values reduce per-chunk overhead; smaller values reduce latency.
#useReadableStream Source
useReadableStream :: forall a b ctx err. ReadableStream a -> (Strom ctx err a -> Om ctx err b) -> Om ctx err bConsume a ReadableStream with guaranteed reader cleanup via Aff.bracket.
The reader is released when the callback completes, errors, or the fiber
is cancelled — unlike fromReadableStream which leaks the reader on
early abandonment.
useReadableStream stream \strom -> do
Strom.runCollect (Strom.takeStrom 5 strom)
#useReadableStreamWith Source
useReadableStreamWith :: forall a b ctx err. { chunkSize :: Int } -> ReadableStream a -> (Strom ctx err a -> Om ctx err b) -> Om ctx err bLike useReadableStream but with a configurable chunk (batch) size.
#runWritable Source
runWritable :: forall a ctx err. WritableStream a -> Strom ctx err a -> Om ctx err UnitDrain a Strom into a WritableStream. Resolves when the stream is fully written. Backpressure comes from the writer's ready promise.
#pipeThrough Source
pipeThrough :: forall a b ctx err. ctx -> (Strom ctx err a -> Strom ctx err b) -> ReadableStream a -> Effect (ReadableStream b)Pipe a ReadableStream through a Strom transformation, producing a new ReadableStream. This is the primary integration point: take web streams, transform them with Strom combinators, and produce a web stream.
Reader cleanup: the reader acquired from the source ReadableStream is released when the transformed stream ends naturally or when the output ReadableStream is cancelled by the consumer.