public void CreateWithState() { const int stateTarget = 27; var state = 0; // ReSharper disable once SuggestVarOrType_SimpleTypes IDisposable disposable = Disposable.CreateWithState(stateTarget, x => state = x); disposable.Dispose(); Assert.That(state, Is.EqualTo(stateTarget)); }
public static IObservable <Sequence> AsObservable(this Sequence self) { return(Observable.Create <Sequence>(observer => { TweenCallback onComplete = null; onComplete = () => { self.onComplete -= onComplete; observer.OnNext(self); observer.OnCompleted(); }; self.onComplete += onComplete; return Disposable.CreateWithState(self, t => t.Kill()); })); }