Example #1
0
                public void OnNext(TLeft value)
                {
                    var s  = new Subject <TRight>();
                    var id = 0;

                    lock (_parent._gate)
                    {
                        id = _parent._leftID++;
                        _parent._leftMap.Add(id, s);
                    }

                    var window = new WindowObservable <TRight>(s, _parent._refCount);

                    // BREAKING CHANGE v2 > v1.x - Order of evaluation or the _leftDurationSelector and _resultSelector now consistent with Join.
                    var md = new SingleAssignmentDisposable();

                    _parent._group.Add(md);

                    var duration = default(IObservable <TLeftDuration>);

                    try
                    {
                        duration = _parent._parent._leftDurationSelector(value);
                    }
                    catch (Exception exception)
                    {
                        OnError(exception);
                        return;
                    }

                    // BREAKING CHANGE v2 > v1.x - The duration sequence is subscribed to before the result sequence is evaluated.
                    md.Disposable = duration.SubscribeSafe(new δ(this, id, s, md));

                    var result = default(TResult);

                    try
                    {
                        result = _parent._parent._resultSelector(value, window);
                    }
                    catch (Exception exception)
                    {
                        OnError(exception);
                        return;
                    }

                    lock (_parent._gate)
                    {
                        _parent._observer.OnNext(result);

                        foreach (var rightValue in _parent._rightMap.Values)
                        {
                            s.OnNext(rightValue);
                        }
                    }
                }
Example #2
0
                public void OnNext(TWindowClosing value)
                {
                    lock (_parent._gate)
                    {
                        _parent._window.OnCompleted();
                        _parent._window = new Subject <TSource>();

                        var window = new WindowObservable <TSource>(_parent._window, _parent._refCountDisposable);
                        _parent._observer.OnNext(window);
                    }
                }
Example #3
0
            public IDisposable Run()
            {
                _window = new Subject <TSource>();
                _gate   = new object();

                var d = new CompositeDisposable(2);

                _refCountDisposable = new RefCountDisposable(d);

                var window = new WindowObservable <TSource>(_window, _refCountDisposable);

                base._observer.OnNext(window);

                d.Add(_parent._source.SubscribeSafe(this));
                d.Add(_parent._windowBoundaries.SubscribeSafe(new ω(this)));

                return(_refCountDisposable);
            }