Namespace: SpawnDev.SpawnJS.JSObjects
Inherits: SpawnJSObject
Source: JSObjects/WritableStreamDefaultController.cs
MDN Reference: WritableStreamDefaultController on MDN
The WritableStreamDefaultController interface of the Streams API represents a controller allowing control of a WritableStream's state. When constructing a WritableStream, the underlying sink is given a corresponding WritableStreamDefaultController instance to manipulate. https://developer.mozilla.org/en-US/docs/Web/API/WritableStreamDefaultController https://streams.spec.whatwg.org/#writablestreamdefaultcontroller
| Property | Type | Access | Description |
|---|---|---|---|
Signal |
AbortSignal |
get | Returns the AbortSignal associated with the controller. |
| Method | Return Type | Description |
|---|---|---|
Error(string message) |
void |
The error() method of the WritableStreamDefaultController interface causes any future interactions with the associated stream to error. This method is rarely used, since usually it suffices to return a rejected promise from one of the underlying sink's methods. However, it can be useful for suddenly shutting down a stream in response to an event outside the normal lifecycle of interactions with the underlying sink. |
SpawnDev.SpawnJS Mapping Note: The JavaScript examples below show the standard Web API usage. In SpawnDev.SpawnJS, the same API is available with C# conventions:
- Properties and methods use PascalCase (e.g.,
readyStatebecomesReadyState)- Events use ActionEvent with
+=/-=(e.g.,addEventListener("click", fn)becomesOnClick += handler)- Async methods return
Task<T>instead ofPromise<T>- Objects should be disposed with
usingstatements- Access via
JS.Get<WritableStreamDefaultController>(...)or constructornew WritableStreamDefaultController(...)
const writableStream = new WritableStream({
start(controller) {
// do stuff with controller
// error stream if necessary
controller.error("My stream is broken");
},
write(chunk, controller) {
// …
},
close(controller) {
// …
},
abort(err) {
// …
},
});