I am not sure if you are looking for a JavaScript solution or something in the System.Reactive
namespace. I have this .NET solution that works. This solution assumes that the Q's will always be generated faster than the T's, i.e. Qn will never be generated after Tn for all n.
// Generate 8 T's, 1 per second.
IObservable<int> tSource =
Observable
.Interval(TimeSpan.FromSeconds(1))
.Select(x => (int)(x + 1))
.Take(8);
// Generate 4 Q's immediately.
IObservable<int> qSource =
(new int[] { 1, 3, 7, 10 })
.ToObservable();
var result =
qSource
.SelectMany(x =>
tSource
.Where(y => x == y)
.Take(1));
Interesting note, this looks like the dual of Gluck's solution which also works.