diff --git a/spec.bs b/spec.bs index ee8436d..0cdebbd 100644 --- a/spec.bs +++ b/spec.bs @@ -704,7 +704,43 @@ For now, see [https://github.com/wicg/observable#operators](https://github.com/w
The filter(|predicate|) method steps are: - 1. TODO: Spec this and use |predicate|. + 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 |sourceObserver| be a new [=internal observer=], initialized as follows: + + : [=internal observer/next steps=] + :: 1. [=Invoke=] |predicate| with the passed in |value|, and let |matches| + 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. If |matches| is true, then run |subscriber|'s {{Subscriber/next()}} method, given + |value|. + + : [=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|.