Example #1
0
        public override IDisposable Subscribe(IObserver <T> observer)
        {
            var cancel = new CancellationDisposable();
            var token  = cancel.Token;
            var source = new FromCoroutine <T>(observer, cancel);

            MainThreadDispatcher.SendStartCoroutine(_coroutine(source, token));
            return(cancel);
        }
Example #2
0
        public override IDisposable Subscribe(IObserver <T> observer)
        {
            CancellationDisposable disposable = new CancellationDisposable();
            FromCoroutine <T>      coroutine  = new FromCoroutine <T>(observer, disposable);

            switch (_type)
            {
            case ETaskObservableType.Default:
                MainThreadDispatcher.SendStartCoroutine(ToEnumerator(coroutine));
                break;

            case ETaskObservableType.WithCancel:
                MainThreadDispatcher.SendStartCoroutine(ToEnumerator(coroutine, disposable.Token));
                break;
            }
            return(disposable);
        }