Created
July 7, 2015 09:23
-
-
Save hacha/8bfb174f9722492a83d1 to your computer and use it in GitHub Desktop.
こういうコンポーネントを持つオブジェクトを、ストリーム発火前にDestoryするとUniRx内でInvalidOperationExceptionが発生するっぽい
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using UniRx; | |
using UniRx.Triggers; | |
public class Test : MonoBehaviour | |
{ | |
void Start () | |
{ | |
var key = this.UpdateAsObservable() | |
.Where(_ => Input.GetKeyDown(KeyCode.A)) | |
.First() | |
.Subscribe(_ => Debug.Log("test")); | |
} | |
} |
破棄される際にOnCompleted()が呼ばれるところで例外発生してるっぽい。
First()をTake(1)にしたら解決したけど、このOnCompleted()時に例外にならないのは何故なんだろう。
First() は空のストリームではエラーだ、空かどうかが判明するのは OnComplete() のときだ。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
試した環境
Unity 5.0.2f1
UniRx 4.8.2
例外発生時のスタックトレース
InvalidOperationException: sequence is empty
UniRx.Stubs.m__1B7 (System.Exception ex) (at Assets/UniRx/Scripts/Observer.cs:180)
UniRx.Observer+AnonymousObserver
1[UniRx.Unit].OnError (System.Exception error) (at Assets/UniRx/Scripts/Observer.cs:71) UniRx.Observable+AnonymousObservable
1+c__AnonStorey117[UniRx.Unit].<>m__1AD (System.Exception ex) (at Assets/UniRx/Scripts/Observable.Creation.cs:35)UniRx.Observer+AnonymousObserver
1[UniRx.Unit].OnError (System.Exception error) (at Assets/UniRx/Scripts/Observer.cs:71) UniRx.Observable+<FirstCore>c__AnonStoreyB7
1+c__AnonStoreyB81[UniRx.Unit].<>m__15D () (at Assets/UniRx/Scripts/Observable.Paging.cs:687) UniRx.Observer+AnonymousObserver
1[UniRx.Unit].OnCompleted () (at Assets/UniRx/Scripts/Observer.cs:87)UniRx.Observable+AnonymousObservable
1+<Subscribe>c__AnonStorey117[UniRx.Unit].<>m__1AE () (at Assets/UniRx/Scripts/Observable.Creation.cs:35) UniRx.Observer+AnonymousObserver
1[UniRx.Unit].OnCompleted () (at Assets/UniRx/Scripts/Observer.cs:87)UniRx.Observer+AnonymousObserver
1[UniRx.Unit].OnCompleted () (at Assets/UniRx/Scripts/Observer.cs:87) UniRx.Subject
1[UniRx.Unit].OnCompleted () (at Assets/UniRx/Scripts/Subjects/Subject.cs:38)UniRx.Triggers.ObservableUpdateTrigger.RaiseOnCompletedOnDestroy () (at Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableUpdateTrigger.cs:27)
UniRx.Triggers.ObservableTriggerBase.OnDestroy () (at Assets/UniRx/Scripts/UnityEngineBridge/Triggers/ObservableTriggerBase.cs:52)