Skip to content

Commit 3a0cfd6

Browse files
committed
Add WritableStream's signal definition for other specs
See WICG/serial#160.
1 parent 5fc90be commit 3a0cfd6

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

index.bs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6941,13 +6941,28 @@ for="ReadableStream">locked</dfn> if ! [$IsReadableStreamLocked$](|stream|) retu
69416941
directly on the [=this=] value inside their constructor steps.</p>
69426942
</div>
69436943

6944-
The following algorithm must only be used on {{WritableStream}} instances initialized via the above
6945-
[=WritableStream/set up=] algorithm:
6944+
The following definitions must only be used on {{WritableStream}} instances initialized via the
6945+
above [=WritableStream/set up=] algorithm:
69466946

69476947
<p algorithm>To <dfn export for="WritableStream" lt="error|erroring">error</dfn> a
69486948
{{WritableStream}} |stream| given a JavaScript value |e|, perform !
69496949
[$WritableStreamDefaultControllerErrorIfNeeded$](|stream|.[=WritableStream/[[controller]]=], |e|).
69506950

6951+
<p>The <dfn export for="WritableStream">signal</dfn> of a {{WritableStream}} |stream| is
6952+
|stream|.[=WritableStream/[[controller]]=].[=WritableStreamDefaultController/[[signal]]=].
6953+
Specifications can [=AbortSignal/add=] or [=AbortSignal/remove=] algorithms to this
6954+
{{AbortSignal}}, or consult whether it is [=AbortSignal/aborted=] and its [=AbortSignal/abort
6955+
reason=]. Specifications should not [=AbortSignal/signal abort=] or make it [=AbortSignal/follow=]
6956+
another {{AbortSignal}}, as that would interfere with the normal use of this signal to respond to
6957+
the stream being [=abort a writable stream|aborted=].
6958+
6959+
<p class="note">The usual usage is, after [=WritableStream/setting up=] the {{WritableStream}},
6960+
[=AbortSignal/add=] an algorithm to its [=WritableStream/signal=], which aborts any ongoing write
6961+
operation to the [=underlying sink=]. Then, inside the <var ignore>[=WritableStream/set
6962+
up/writeAlgorithm=]</var>, once the [=underlying sink=] has responded, check if the
6963+
[=WritableStream/signal=] is [=AbortSignal/aborted=], and [=reject=] the returned promise with the
6964+
signal's [=AbortSignal/abort reason=] if so.
6965+
69516966
<h4 id="other-specs-ws-writing">Writing</h4>
69526967

69536968
The following algorithms can be used on arbitrary {{WritableStream}} instances, including ones that

0 commit comments

Comments
 (0)