上海虹口龙之梦项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

37 lines
1.1 KiB

using System;
#if UniRxLibrary
using UnityObservable = UniRx.ObservableUnity;
#else
using UnityObservable = UniRx.Observable;
#endif
namespace UniRx.Operators
{
internal class DelayFrameSubscriptionObservable<T> : OperatorObservableBase<T>
{
readonly IObservable<T> source;
readonly int frameCount;
readonly FrameCountType frameCountType;
public DelayFrameSubscriptionObservable(IObservable<T> source, int frameCount, FrameCountType frameCountType)
: base(source.IsRequiredSubscribeOnCurrentThread())
{
this.source = source;
this.frameCount = frameCount;
this.frameCountType = frameCountType;
}
protected override IDisposable SubscribeCore(IObserver<T> observer, IDisposable cancel)
{
var d = new MultipleAssignmentDisposable();
d.Disposable = UnityObservable.TimerFrame(frameCount, frameCountType)
.SubscribeWithState3(observer, d, source, (_, o, disp, s) =>
{
disp.Disposable = s.Subscribe(o);
});
return d;
}
}
}