diff --git a/spec.bs b/spec.bs index 6db9875..ee8436d 100644 --- a/spec.bs +++ b/spec.bs @@ -659,7 +659,46 @@ For now, see [https://github.com/wicg/observable#operators](https://github.com/w
map(|mapper|)
method steps are:
- 1. TODO: Spec this and use |mapper|.
+ 1. Let |sourceObservable| be [=this=].
+
+ 1. Let |observable| be a [=new=] {{Observable}} whose [=Observable/subscribe callback=] is an
+ algorithm that takes a {{Subscriber}} |subscriber| and does the following:
+
+ 1. Let |controller| be a [=new=] {{AbortController}}.
+
+ 1. Let |idx| be an {{unsigned long long}}, initially 0.
+
+ 1. Let |sourceObserver| be a new [=internal observer=], initialized as follows:
+
+ : [=internal observer/next steps=]
+ :: 1. [=Invoke=] |mapper| with the passed in value, and |idx|, and let
+ |mappedValue| be the returned value.
+
+ If an exception |E| was thrown,
+ then run |subscriber|'s {{Subscriber/error()}} method, given |E|,
+ [=AbortController/signal abort=] |controller|, and abort these steps.
+
+ 1. Increment |idx|.
+
+ 1. Run |subscriber|'s {{Subscriber/next()}} method, given |mappedValue|.
+
+ : [=internal observer/error steps=]
+ :: Run |subscriber|'s {{Subscriber/error()}} method, given the passed in error.
+
+ : [=internal observer/complete steps=]
+ :: Run |subscriber|'s {{Subscriber/complete()}} method.
+
+ 1. Let |signal| be the result of [=creating a dependent abort signal=] from the list
+ «|controller|'s [=AbortController/signal=], |subscriber|'s [=Subscriber/signal=]», using
+ {{AbortSignal}}, and the [=current realm=].
+
+ 1. Let |options| be a new {{SubscribeOptions}} whose {{SubscribeOptions/signal}} is |signal|.
+
+ 1. Subscribe to |sourceObservable|
+ given |sourceObserver| and |options|.
+
+ 1. Return |observable|.