Simply Ged

Simply Ged Simply Ged

Niner since 2008

Comments

  • Rx Workshop: Programming the Cloud

    I got this to work, although I'm not sure if I could have made the action into an anonymous method?

    public IDisposable Subscribe(IObserver<R> observer)
    {
        GenerateState state = new GenerateState
        {
            condition = this.condition,
            current = this.initial,
            iterate = this.iterate,
            observer = observer,
            resultSelector = this.resultSelector
        };
    
        Action<GenerateState, Action<GenerateState>> action = (_state, self) =>
        {
            if (_state.condition(_state.current))
            {
                var result = _state.resultSelector(_state.current);
                _state.observer.OnNext(result);
                _state.current = _state.iterate(_state.current);
    
                self(_state);
            }
            else
                _state.observer.OnCompleted();
        };
    
        return scheduler.Schedule(state, action);
    }