title: emit an object as the value of an observable timer
body: <p>I need to replay a sequence of events stored in a database. So I want to create an Observable stream of Observable timers that ellapse when every event must emit. My problem is that I can't find the appropiate way to have an object be emitted as the value of the timer.</p>
  
  <p>Let me set a simplified (and somewhat contrived) example, but that explains the problem.</p>
  
  <p>Let's begin with a simple array of delay values</p>
  
  <pre><code>var delays = [200,100,1000,1200,300,1100];
  </code></pre>
  
  <p>and their corresponding Observable timers</p>
  
  <pre><code>var source= Rx.Observable
    .for(delays, t =&gt; Rx.Observable.timer(t) );
  </code></pre>
  
  <p>which I can observe</p>
  
  <pre><code>source.subscribe( x =&gt; console.log(x) );
  </code></pre>
  
  <p>so far so good, obtaining just a list of zeroes at each timer completition.</p>
  
  <p>Then, for the purpouses of this example, I'd like to obtain the events fired at the delay expressed, not in the original order; and I'd like to obtain the original value and index into the array of each timer.</p>
  
  <p>So, I add a simple map in the observable</p>
  
  <pre><code>var source= Rx.Observable
    .for(delays, t =&gt; Rx.Observable.timer(t) )
    .map((x,i)=&gt;{i,x}); 
  </code></pre>
  
  <p>And, to check if the timing is acurate, I add a watch in the observer,</p>
  
  <pre><code>  var startTime = Date.now();    
    source.subscribe( x =&gt; console.log((Date.now()-startTime), x) );
  </code></pre>
  
  <blockquote>
    <p><strong><em>this is what I'd like to obtain</em></strong></p>
  
  <pre><code>142 { i:1, x:100 }
  204 { i: 0, x: 200 }
  303 { i: 4, x: 300 }
  1002 { i: 2, x: 1000 }
  1101 { i: 5, x: 1100 }
  1203 { i: 3, x: 1200 }
  </code></pre>
  </blockquote>
  
  <p>I don't get the original index in the array, but the order in which they are being emitted. </p>
  
  <blockquote>
    <p><strong><em>this is what I obtain instead</em></strong></p>
  
  <pre><code>1046 { x: 0, i: 0 }
  1166 { x: 0, i: 1 }
  1371 { x: 0, i: 2 }
  2472 { x: 0, i: 3 }
  3673 { x: 0, i: 4 }
  3974 { x: 0, i: 5 }
  </code></pre>
  </blockquote>
  
  <p>What is the most RxJS-esque technique to have an object be emitted as the value of a timer?</p>