Re: [whatwg/streams] Add explainer for WritableStreamDefaultController's AbortSignal (#1162)

@nidhijaju commented on this pull request.



> +## Examples
+
+These are some examples of Javascript which can be used for writable streams once this is implemented:
+
+In this example, the underlying sink write waits 1 second to simulate a long-running operation. However, if abort() is
+called it stops immediately.
+
+
+```javascript
+const ws = new WritableStream({
+  write(controller) {
+    return new Promise((resolve, reject) => {
+      setTimeout(resolve, 1000);
+      controller.signal.addEventListener('abort',
+        () => reject(controller.abortReason()));
+});

Done, I've added the correct parentheses/brackets here.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/1162#discussion_r698484762

Received on Monday, 30 August 2021 13:24:52 UTC