Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to paste relative delay in Observable sequence with Rx (Reactive Extensions)
    text
    copied!<p>I'm starting the development with Reactive extensions (version 2.1, just in case) and for my sample application I need a sequence of int values pushed with some interval, i.e. every 1 second.</p> <p>I know, that I can create a sequence with <code>Observable.Range&lt;int&gt;(0,10)</code> but I can't figure out how to set relative time between pushes. I've tried <code>Delay()</code> but shifts the sequence only once at the start.</p> <p>I then found <code>Observable.Generate()</code> method that could be adjusted to this task in next way:</p> <pre><code>var delayed = Observable. Generate(0, i =&gt; i &lt;= 10, i =&gt; i + 1, i =&gt; i, i =&gt; TimeSpan.FromSeconds(1)); </code></pre> <p>But that seems to be working only for simple 'for-each-like' defined sequences. So, in general, my question is, whether we can to get any source sequence and wrap it with some proxy that will pull messages from source and push it further with time delay?</p> <pre><code>S--d1--d2--d3--d4--d5-| D--d1-delay-d2-delay-d3-delay-d4-delay-d5-| </code></pre> <p><strong>P.S.</strong> If this approach contradicts to the concept of ReactiveExtensions, please also note this. I don't want to do it "by all means" and them get some other design problems in future.</p> <p><em><strong>P.P.S</em></strong> General Idea is to make sure that <strong><em>output sequence has a specified interval between events</em></strong> in spite of if the input sequence is finite or infinite and how often it pushes events.</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