-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented UnderlyingSource
and added a trivial ReadableStream
constructor
#254
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
/// **cancel(reason), of type UnderlyingSourceCancelCallback** | ||
/// A function that is called whenever the consumer cancels the stream, via stream.cancel() or reader.cancel(). It takes as its argument the same value as was passed to those methods by the consumer. | ||
/// | ||
/// Readable streams can additionally be canceled under certain conditions during piping; see the definition of the pipeTo() method for more details. | ||
/// | ||
// For all streams, this is generally used to release access to the underlying resource; see for example § 10.1 A readable stream with an underlying push source (no backpressure support). | ||
/// | ||
/// If the shutdown process is asynchronous, it can return a promise to signal success or failure; the result will be communicated via the return value of the cancel() method that was called. Throwing an exception is treated the same as returning a rejected promise. | ||
/// | ||
/// [spec]: https://streams.spec.whatwg.org/#dom-underlyingsource-cancel | ||
/// | ||
/// *Even if the cancelation process fails, the stream will still close; it will not be put into an errored state. This is because a failure in the cancelation process doesn’t matter to the consumer’s view of the stream, once they’ve expressed disinterest in it by canceling. The failure is only communicated to the immediate caller of the corresponding method.* | ||
/// | ||
/// *This is different from the behavior of the close and abort options of a WritableStream's underlying sink, which upon failure put the corresponding WritableStream into an errored state. Those correspond to specific actions the producer is requesting and, if those actions fail, they indicate something more persistently wrong.* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe: split long comments into multiple lines ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
49abf91
to
b12ebc5
Compare
2aca812
to
eba20f3
Compare
eba20f3
to
36f2a08
Compare
Deployed at sr17g48DgXQqTZGdiNhn6d4Ar9qQd12tWnwh |
Description
Implemented
UnderlyingSource
, and added a trivialReadableStream
constructor that only transforms its first input into anUnderlyingSource
.A few other things were added to make this possible / easier:
JsFn<T, I, O>
forJsFunction
that allows to be more explicit about the JS function we expect to have, and to automatically handle theTryFromJs
andIntoJs
conversion for inputs and outputs.Todo
placeholder type for types from the spec that have not been defined yet.Manual testing
One can also add
in the
constructor
ofReadableStreamClass
and then test it withChecklist
make fmt-check
to check)