proebuck (60) [Avatar] Offline
#1
I'd like a little more explanation for this listing. While I get the basic idea,
not sure I understand why callout 3 would work. It would seem to be returning
the completion callback, but shouldn't it be creating an Observable object
containing the completion callback instead?
331872 (131) [Avatar] Offline
#2
By the third callout, are you referring to

return () => clearTimeout(timeoutId);

?
If so, what's happening here is that the observer function returns a value (itself a function) that defines the body of code to invoke when the unsubscribe() method is called on the observer (or on the unsubscription).

Remember that in this case source$ is an instance of type Subscription, with an unsubscribe() method. The logic to invoke when this method is called for a custom Observable is outcome of invoking that function, in this case: () => clearTimeout(timeoutId);

Hope this makes sense.