tc39/proposal-observable

`ExecuteSubscriber` should either memoize `unsubscribe` or defer the check

dead-claudia opened this issue · 1 comments

It seems odd that ExecuteSubscriber both checks for unsubscribe early and accesses it later, unlike everywhere else in the spec. I feel it'd make more sense to:

  1. Memoize the method and use that.
  2. Defer the check until the subscription cleanup function is called.

The second IMHO would make more sense, since it takes less memory and is more common in the rest of the ES spec.

I think option 2 makes sense. In that case, I think we should no longer throw a TypeError if the subscriber return value is not one of null, undefined, a function , or an object with an "unsubscribe" method (although we should still throw if the value has an "unsubscribe" property that is not callable).

I've create a PR for zen-observable based on this suggestion in zenparsing/zen-observable#38.