Say I have an Observable<LogEntry>
, where LogEntry
has a property TimeStamp
(among others of course). The LogEntry
s are created by reading a logfile.
public IObservable<LogEntry> GetLogRecords()
{
return Observable.Create<LogEntry>(
(IObserver<LogEntry> observer) =>
{
var lines = File.ReadLines(this.filePath);
var enumerator = lines.GetEnumerator();
while (enumerator.MoveNext())
{
string line = enumerator.Current;
if (!line.StartsWith("#"))
{
var entry = new LogEntry(line);
observer.OnNext(entry);
}
}
observer.OnCompleted();
return Disposable.Create(() => Console.WriteLine("Unsubscribed"));
});
}
That Observable will 'fire' as fast as the file is read.
What I want is to space (delay) the events by the time span between the second last and the last LogEntry.TimeStamp
eg. something along the line
var replayObs = GetLogEntries().Delay(calculatedTimeDiff);