readable_controller.Rd
The controller object passed to the ReadableStream's functions is a list with references to the underlying stream object.
Members:
desired_size
start_value
Methods:
emit
enqueue
close
error
desired_size
Reference to streams::ReadableStream$desired_size
start_value
The return value of the stream's start function
# the start value can be used to store a connection for
# reference during the pull method
r <- ReadableStream$new(
start = function(controller) {
x <- file(tempfile())
if (!isOpen(x)) {
open(x)
}
x
},
pull = function(controller) {
out <- readLines(c$start_value, n = 1L)
if (length(out) > 0L) {
c$enqueue(out)
} else {
c$close()
}
}
)
enqueue()
Pushes a chunk of data into the stream's internal queue
close()
Order the stream to close when possible.
Specifically, the stream will enter a "close_requested" state.
Whenever the internal buffer reaches a size of 0
, the stream will stop processing data and will close.
error()
Orders the stream to be put into an errored state.
streams::ReadableStream