Exemplo n.º 1
0
 static async Task BufferTimeHoppingAsync()
 {
     await
     AsyncObservable
     .Interval(TimeSpan.FromMilliseconds(300))
     .Buffer(TimeSpan.FromSeconds(1))
     .Select(xs => string.Join(", ", xs))
     .SubscribeAsync(Print <string>());        // TODO: Use ForEachAsync.
 }
Exemplo n.º 2
0
 static async Task CombineLatestAsync()
 {
     await
     AsyncObservable.CombineLatest(
         AsyncObservable.Interval(TimeSpan.FromMilliseconds(250)).Take(10).Timestamp(),
         AsyncObservable.Interval(TimeSpan.FromMilliseconds(333)).Take(10).Timestamp(),
         (x, y) => x.ToString() + ", " + y.ToString()
         )
     .SubscribeAsync(Print <string>());    // TODO: Use ForEachAsync.
 }
Exemplo n.º 3
0
 static async Task BufferTimeSlidingAsync()
 {
     await
     AsyncObservable
     .Interval(TimeSpan.FromMilliseconds(100))
     .Timestamp(TaskPoolAsyncScheduler.Default)
     .Buffer(TimeSpan.FromSeconds(1), TimeSpan.FromMilliseconds(300))
     .Select(xs => $"[{xs.First().Timestamp}, {xs.Last().Timestamp}] = {(xs.Last().Timestamp - xs.First().Timestamp).TotalMilliseconds}")
     .SubscribeAsync(Print <string>());        // TODO: Use ForEachAsync.
 }
Exemplo n.º 4
0
 static async Task GroupBySelectManyAsync()
 {
     await
     AsyncObservable.Interval(TimeSpan.FromMilliseconds(250))
     .Timestamp()
     .Take(20)
     .GroupBy(t => t.Timestamp.Millisecond / 100)
     .SelectMany(g => g, (g, x) => g.Key + " - " + x)
     .SubscribeAsync(Print <string>());
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RxCanon{TElement}"/> class.
 /// </summary>
 public RxCanon()
 {
     // 100 ms by default
     TimeInterval = 100;
     // Source observable
     Source = AsyncObservable
              .Interval(TimeSpan.FromMilliseconds(TimeInterval))
              .SelectMany(i => PullAll())
              .Timestamp();
     // For debug
     _disposeDebug = Subscribe(PrintAsync <Timestamped <TElement> >());
 }