You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In section 2.2.2, Observable.from iteration functions assume that their observer argument is in fact a native subscription observer, when a subclass constructor could choose to pass it any value, including a primitive. Instead, it should do three things:
In the first step, a TypeError if Type(observer) is not Object.
In step 5.e, use ? ToBoolean(? GetV(observer, "closed")) instead of SubscriptionClosed(subscription) to determine closure status. It should also be determined prior to sending the value.
When invoking observer methods, use ? instead of !, since it's not invariant.
Also, as a couple drive-by issues, the GetIterator call should use iterator, not items, and the last step in the loop should return undefined rather than the iterator result, for consistency.
The fixed body would read like this:
Let iterable be the value of the [[Iterable]] internal slot of F.
Let iteratorMethod be the value of the [[IteratorMethod]] internal slot of F.
Let iterator be ? GetIterator(iterable, iteratorMethod).
Repeat
If ? ToBoolean(? GetV(observer, "closed")) is true, then
In JS, this would roughly be the following callback:
functionmakeFromCallback(iterable,iteratorMethod){returnobserver=>{constiterator=Call(iteratorMethod,iterable)if(!IsObject(iterator)){thrownewTypeError("`x[Symbol.iterator]()` must return an object!")}// Technically wrong, but unobservable:// https://github.com/tc39/ecma262/pull/1288constnextMethod=GetMethod(iterator,"next")while(!observer.closed){constresult=Call(nextMethod,iterator)if(!IsObject(result)){thrownewTypeError("`iterator.next()` must return an object!")}if(result.done){observer.complete()return}observer.next(result.value)}constreturnMethod=GetMethod(iterator,"return")if(returnMethod!=null&&!IsObject(Call(returnMethod,iterator))){thrownewTypeError("`iterator.return()` must return an object!")}}}
The text was updated successfully, but these errors were encountered:
In section 2.2.2,
Observable.from
iteration functions assume that their observer argument is in fact a native subscription observer, when a subclass constructor could choose to pass it any value, including a primitive. Instead, it should do three things:TypeError
if Type(observer) is not Object."closed"
)) instead of SubscriptionClosed(subscription) to determine closure status. It should also be determined prior to sending the value.Also, as a couple drive-by issues, the GetIterator call should use iterator, not items, and the last step in the loop should return
undefined
rather than the iterator result, for consistency.The fixed body would read like this:
"closed"
)) istrue
, thenundefined
).undefined
.false
, thenundefined
."next"
, « nextValue »).In JS, this would roughly be the following callback:
The text was updated successfully, but these errors were encountered: