Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>Doesn't this operation require that mm is "looked at" independently twice?</p> </blockquote> <p>Thats in fact the answer of your question: You can subscribe to the same <code>IObservable</code> sequence multiple times.</p> <p>The <code>mm.Skip(1)</code> subscribes to <code>mm</code> and hides the first value to its own subscribers. Zip is a subscriber of both <code>mm.Skip(1)</code> and <code>mm</code>. Because <code>mm</code> yielded one more value than <code>mm.Skip(1)</code>, Zip internally buffers the last mousemove event from <code>mm</code> all the time in order to zip it with the next future mousemove event. The selector function can then select the delta between both.</p> <p>Another thing you should notice is (which is the real answer to the title of your question), that this <code>Observable.FromEvent</code>-<code>IObservable</code> is a <strong>hot</strong> observable and therefore <strong>not repeatable</strong>. But there are <strong>cold</strong> Observables which are in fact <strong>repeatable</strong>, like Observable.Range(0,10). In the latter case each subscriber will receive the same 10 events, because they are generated independently for each subscriber. For mousemove events this is not the case (you wont get mouse move events from the past). But because Zip subscribes to the right and left sequence at the same time its likely the same in this case.</p> <p>P.S.: You can also crate a hot / not repeatable <code>IEnumerable</code>: It does not need to return the same values for each enumerator. You could for instance create an IEnumerable which waits until a mousemove event occurs an then yield the event. In this case the enumerator would always block (bad design), but it would be possible. ;)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload