Force flush to Observable.Buffer c#

后端 未结 2 1232
鱼传尺愫
鱼传尺愫 2021-01-06 03:11

Is there any way to force a Observable.Buffer to flush before the end of buffered time?

In the example:

mSubscription = mFluxObservable.Buffer(new Time

2条回答
  •  伪装坚强ぢ
    2021-01-06 04:07

    This worked for me:

    var subject = new Subject();
    var closing = Observable
        .Timer(new TimeSpan(0, 0, 1, 30))
        .Select(x => Unit.Default);
    
    var query =
        mFluxObservable
            .Buffer(() => Observable
                .Amb(subject, closing)
                .Take(1));
    

    Now I only need to call subject.OnNext(Unit.Default) to force the buffer to flush. A new buffer is started immediately after the flush.

提交回复
热议问题