protected override IDisposable SubscribeCore(UniRx.IObserver <T> observer, IDisposable cancel) { if (predicate == null) { return(source.Subscribe(new First(this, observer, cancel))); } return(source.Subscribe(new First_(this, observer, cancel))); }
protected override IDisposable SubscribeCore(UniRx.IObserver <TR> observer, IDisposable cancel) { if (selector != null) { return(source.Subscribe(new Select(this, observer, cancel))); } return(source.Subscribe(new Select_(this, observer, cancel))); }
protected override IDisposable SubscribeCore(UniRx.IObserver <Unit> observer, IDisposable cancel) { if (onNext != null) { return(source.Subscribe(new ForEachAsync(this, observer, cancel))); } return(source.Subscribe(new ForEachAsync_(this, observer, cancel))); }
public ReadOnlyReactiveProperty(UniRx.IObservable <T> source, T initialValue, bool distinctUntilChanged) { this.distinctUntilChanged = distinctUntilChanged; value = initialValue; canPublishValueOnSubscribe = true; sourceConnection = source.Subscribe(new ReadOnlyReactivePropertyObserver(this)); }
public IDisposable Run() { length = sources.Length; if (length == 0) { OnNext(new T[0]); try { base.observer.OnCompleted(); } finally { Dispose(); } return(Disposable.Empty); } completedCount = 0; values = new T[length]; IDisposable[] array = new IDisposable[length]; for (int i = 0; i < length; i++) { UniRx.IObservable <T> observable = sources[i]; WhenAllCollectionObserver observer = new WhenAllCollectionObserver(this, i); array[i] = observable.Subscribe(observer); } return(StableCompositeDisposable.CreateUnsafe(array)); }
public IDisposable Run() { isFirstSubscribe = true; isDisposed = false; isStopped = false; e = parent.sources.GetEnumerator(); subscription = new SerialDisposable(); schedule = new SingleAssignmentDisposable(); UniRx.IObservable <Unit> trigger = parent.trigger; Action <Unit> onNext = delegate { lock (gate) { isStopped = true; e.Dispose(); subscription.Dispose(); schedule.Dispose(); base.observer.OnCompleted(); } }; UniRx.IObserver <T> observer = base.observer; stopper = trigger.Subscribe(onNext, observer.OnError); schedule.Disposable = Scheduler.CurrentThread.Schedule(RecursiveRun); return(new CompositeDisposable(schedule, subscription, stopper, Disposable.Create(delegate { lock (gate) { isDisposed = true; e.Dispose(); } }))); }
public IDisposable Subscribe(UniRx.IObserver <TElement> observer) { IDisposable disposable = refCount.GetDisposable(); IDisposable disposable2 = subject.Subscribe(observer); return(StableCompositeDisposable.Create(disposable, disposable2)); }
private void RecursiveRun(Action self) { lock (gate) { nextSelf = self; if (!isDisposed && !isStopped) { UniRx.IObservable <T> observable = null; bool flag = false; Exception ex = null; try { flag = e.MoveNext(); if (flag) { observable = e.Current; if (observable == null) { throw new InvalidOperationException("sequence is null."); } } else { e.Dispose(); } } catch (Exception ex2) { ex = ex2; e.Dispose(); } if (ex != null) { stopper.Dispose(); observer.OnError(ex); } else if (!flag) { stopper.Dispose(); observer.OnCompleted(); } else { UniRx.IObservable <T> current = e.Current; SingleAssignmentDisposable singleAssignmentDisposable = new SingleAssignmentDisposable(); subscription.Disposable = singleAssignmentDisposable; if (isFirstSubscribe) { isFirstSubscribe = false; singleAssignmentDisposable.Disposable = current.Subscribe(this); } else { MainThreadDispatcher.SendStartCoroutine(SubscribeAfterEndOfFrame(singleAssignmentDisposable, current, this, parent.lifeTimeChecker)); } } } } }
protected override IDisposable SubscribeCore(UniRx.IObserver <T> observer, IDisposable cancel) { if (scheduler == null) { return(source.Subscribe(new Skip(this, observer, cancel))); } return(new Skip_(this, observer, cancel).Run()); }
public IDisposable Subscribe(UniRx.IObserver <U> observer) { if (observer == null) { throw new ArgumentNullException("observer"); } return(observable.Subscribe(observer)); }
public override void OnNext(UniRx.IObservable <T> value) { SingleAssignmentDisposable singleAssignmentDisposable = new SingleAssignmentDisposable(); collectionDisposable.Add(singleAssignmentDisposable); Merge observer = new Merge(this, singleAssignmentDisposable); singleAssignmentDisposable.Disposable = value.Subscribe(observer); }
private static IEnumerator SubscribeAfterEndOfFrame(SingleAssignmentDisposable d, UniRx.IObservable <T> source, IObserver <T> observer, GameObject lifeTimeChecker) { yield return(YieldInstructionCache.WaitForEndOfFrame); if (!d.IsDisposed && lifeTimeChecker != null) { d.Disposable = source.Subscribe(observer); } }
private void Subscribe(UniRx.IObservable <T> innerSource) { SingleAssignmentDisposable singleAssignmentDisposable = new SingleAssignmentDisposable(); collectionDisposable.Add(singleAssignmentDisposable); Merge observer = new Merge(this, singleAssignmentDisposable); singleAssignmentDisposable.Disposable = innerSource.Subscribe(observer); }
public void Color(UniRx.IObservable <UnityEngine.Color> color) { var g = gObject; var sub = color.Subscribe((c) => { g.titleColor = c; }); uiBase.AddDisposable(sub); }
protected override IDisposable SubscribeCore(UniRx.IObserver <T> observer, IDisposable cancel) { if (dueTimeT.HasValue) { MultipleAssignmentDisposable d = new MultipleAssignmentDisposable(); TimeSpan dueTime = Scheduler.Normalize(dueTimeT.Value); d.Disposable = scheduler.Schedule(dueTime, delegate { d.Disposable = source.Subscribe(observer); }); return(d); } MultipleAssignmentDisposable d2 = new MultipleAssignmentDisposable(); d2.Disposable = scheduler.Schedule(dueTimeD.Value, (Action) delegate { d2.Disposable = source.Subscribe(observer); }); return(d2); }
protected override IDisposable SubscribeCore(UniRx.IObserver <T> observer, IDisposable cancel) { SingleAssignmentDisposable singleAssignmentDisposable = new SingleAssignmentDisposable(); SerialDisposable d = new SerialDisposable(); d.Disposable = singleAssignmentDisposable; singleAssignmentDisposable.Disposable = scheduler.Schedule(delegate { d.Disposable = new ScheduledDisposable(scheduler, source.Subscribe(observer)); }); return(d); }
public override void OnNext(UniRx.IObservable <T> value) { ulong id = 0uL; lock (gate) { id = ++latest; hasLatest = true; } SingleAssignmentDisposable singleAssignmentDisposable = new SingleAssignmentDisposable(); innerSubscription.Disposable = singleAssignmentDisposable; singleAssignmentDisposable.Disposable = value.Subscribe(new Switch(this, id)); }
public ObservableYieldInstruction(UniRx.IObservable <T> source, bool reThrowOnError, CancellationToken cancel) { moveNext = true; this.reThrowOnError = reThrowOnError; this.cancel = cancel; try { subscription = source.Subscribe(new ToYieldInstruction(this)); } catch { moveNext = false; throw; } }
internal YieldInstruction(UniRx.IObservable <T> source, bool rethrowOnError) { this.rethrowOnError = rethrowOnError; try { var observer = new ObserverYieldInstruction(this); subscription = source.Subscribe(observer); } catch { moveNext = false; throw; } }
public override void OnCompleted() { if (seenValue) { UniRx.IObservable <TResult> observable = parent.selector(lastValue); serialDisposable.Disposable = observable.Subscribe(observer); } else { try { observer.OnCompleted(); } finally { Dispose(); } } }
public T Run() { semaphore = new ManualResetEvent(initialState: false); using (source.Subscribe(this)) { if (!((!(timeout == InfiniteTimeSpan)) ? semaphore.WaitOne(timeout) : semaphore.WaitOne())) { throw new TimeoutException("OnCompleted not fired."); } } if (ex != null) { throw ex; } if (!seenValue) { throw new InvalidOperationException("No Elements."); } return(value); }
public static IDisposable LogToUnityDebug(this UniRx.IObservable <LogEntry> source) { return(source.Subscribe(new UnityDebugSink())); }
protected override IDisposable SubscribeCore(UniRx.IObserver <T> observer, IDisposable cancel) { return(source.Subscribe(new Synchronize(this, observer, cancel))); }
protected override IDisposable SubscribeCore(UniRx.IObserver <TimeInterval <T> > observer, IDisposable cancel) { return(source.Subscribe(new FrameTimeInterval(this, observer, cancel))); }
protected override IDisposable SubscribeCore(UniRx.IObserver <TResult> observer, IDisposable cancel) { return(source.Subscribe(new OfType(observer, cancel))); }
public ReadOnlyReactiveProperty(UniRx.IObservable <T> source) { sourceConnection = source.Subscribe(new ReadOnlyReactivePropertyObserver(this)); }
public ReadOnlyReactiveProperty(UniRx.IObservable <T> source, T initialValue) { value = initialValue; canPublishValueOnSubscribe = true; sourceConnection = source.Subscribe(new ReadOnlyReactivePropertyObserver(this)); }
public ReadOnlyReactiveProperty(UniRx.IObservable <T> source, bool distinctUntilChanged) { this.distinctUntilChanged = distinctUntilChanged; sourceConnection = source.Subscribe(new ReadOnlyReactivePropertyObserver(this)); }
protected override IDisposable SubscribeCore(UniRx.IObserver <TSource> observer, IDisposable cancel) { return(source.Subscribe(new Aggregate(this, observer, cancel))); }
public FacebookRunner() { SceneLoader root = SceneLoader.Instance; Singleton <PropertyManager> .Instance.AddRootContext(this); IsLoggedToFacebook = PersistentSingleton <FacebookAPIService> .Instance.IsLoggedToFB.ToReactiveProperty(); FacebookEvents = m_fbEventsInternal.AsObservable(); FacebookEvents.Subscribe(delegate(UniRx.Tuple <FacebookEvent, object> e) { switch (e.Item1) { case FacebookEvent.LOGIN_CANCELLED: case FacebookEvent.LOGIN_FAILED: break; case FacebookEvent.NEW_FRIENDS_FETCHED: break; case FacebookEvent.ADD_FRIEND_REQUEST_ERROR: break; case FacebookEvent.LOGIN_ATTEMPT: HandleLoginAttempt((ILoginResult)e.Item2); break; case FacebookEvent.LOGIN: RequestFBData(); break; case FacebookEvent.MY_DATA: HandleMyFBData((MyFacebookData)e.Item2); GetAllRequests(); break; case FacebookEvent.FRIEND_DATA: HandleFriendFBData((FBPlayer)e.Item2); GiftsFetched.OnNext(value: true); break; case FacebookEvent.ALL_REQUESTS: HandleAllRequests((IGraphResult)e.Item2); break; case FacebookEvent.APP_REQUEST_RESULT: HandleAppRequestResult((IAppRequestResult)e.Item2); break; case FacebookEvent.FRIEND_REQUEST_RESULT: HandleFBFriendAppRequest((FBPlayer)e.Item2); GiftsFetched.OnNext(value: true); break; } }).AddTo(root); GiftConsuming.Subscribe(delegate { GiftOpenInProgress.Value++; }).AddTo(root); GiftConsumeFailed.Subscribe(delegate { GiftOpenInProgress.Value--; }).AddTo(root); GiftConsumeSuccess.Subscribe(delegate { GiftOpenInProgress.Value--; }).AddTo(root); GiftSending.Subscribe(delegate { GiftSendInProgress.Value++; }).AddTo(root); GiftSendingFailed.Subscribe(delegate { GiftSendInProgress.Value--; }).AddTo(root); GiftSendingSuccess.Subscribe(delegate { GiftSendInProgress.Value--; }).AddTo(root); GiftOpenBlocked = (from count in GiftOpenInProgress select count != 0).TakeUntilDestroy(root).ToReadOnlyReactiveProperty(); GiftSendBlocked = (from count in GiftSendInProgress select count != 0).TakeUntilDestroy(root).ToReadOnlyReactiveProperty(); GiftOpenAvailable = (from _ in (from _ in GiftOpenInProgress select true).Merge(GiftsFetched) select UniqueGifts().Count > 0).TakeUntilDestroy(root).ToReadOnlyReactiveProperty(); GiftSendAvailable = (from _ in (from _ in GiftSendInProgress select true).Merge(GiftsFetched) select !AreAllPlayersGifted()).TakeUntilDestroy(root).ToReadOnlyReactiveProperty(); GiftConsumeSuccess.Subscribe(delegate(FacebookGift gift) { MaybeSendBackGift(m_consumedFrom, gift.FromId); }).AddTo(root); (from pause in Observable.EveryApplicationPause().StartWith(value: false) where !pause && IsLoggedToFacebook.Value select pause).Subscribe(delegate { GetAllRequests(); }).AddTo(root); (from tuple in PlayerData.Instance.LifetimeChunk.CombineLatest(PlayerData.Instance.FBId, (int highscore, string player) => new { highscore, player }) where tuple.player != string.Empty && PersistentSingleton <FacebookAPIService> .Instance.FBPlayers.ContainsKey(tuple.player) where tuple.highscore > PersistentSingleton <FacebookAPIService> .Instance.FBPlayers[tuple.player].Highscore select tuple).Subscribe(tuple => { PersistentSingleton <FacebookAPIService> .Instance.FBPlayers[tuple.player].Highscore = tuple.highscore; }).AddTo(root); (from e in FacebookEvents where e.Item1 == FacebookEvent.LOGIN select(AccessToken) e.Item2).Subscribe(delegate(AccessToken access) { PersistentSingleton <PlayFabService> .Instance.LoggedOnPlayerId.Take(1).Subscribe(delegate { JSONObject customInfo = PersistentSingleton <PlayFabService> .Instance.GetCustomInfo(); SyncToFacebook(access, customInfo, delegate(JSONObject json) { string a = json.asString("PlayFabId", () => string.Empty); if (a != PersistentSingleton <PlayFabService> .Instance.LoggedOnPlayerId.Value) { PersistentSingleton <PlayFabService> .Instance.ClearCmdQueue(); PlayerData.Instance.LastSavedToCloud.Value = 0L; PersistentSingleton <PlayFabService> .Instance.LoggedOnPlayerId.UnpublishValue(); PersistentSingleton <PlayFabService> .Instance.ShouldLoginImmediately = true; SceneLoadHelper.LoadInitScene(); } }, null); }).AddTo(root); }).AddTo(root); (from e in FacebookEvents where e.Item1 == FacebookEvent.MY_DATA select(from f in ((MyFacebookData)e.Item2).Friends where ((Dictionary <string, object>) f).ContainsKey("id") select(string)((Dictionary <string, object>) f)["id"]).ToList()).Subscribe(delegate(List <string> list) { PersistentSingleton <PlayFabService> .Instance.GetPlayFabToFacebookIdMapping(list, delegate(Dictionary <string, string> fbToPf) { PlayerData.Instance.PlayFabToFBIds.Value = fbToPf; UpdateLeaderboards.SetValueAndForceNotify(value: true); }, null); }).AddTo(root); (from logged in IsLoggedToFacebook where logged select logged).Subscribe(delegate { OnLoggedIn(); }).AddTo(root); }