Blogging on the Train

I am looking to update my blog from the train on my daily commute. The main hurdle to overcome is the fact that the computer will not be connected to the internet during this time. And so the hunt for a decent offline blog editor begins.

The obvious place to start is Windows Live Writer.

I need to find out how to post source code using it. Apparently there is a plug in.

Watch this space.

Observable Cache

Source Code:

Given: An async operation that returns a value e.g web/service call or complex calculation
When: I request the value multiple times
Then: I only perform the operation once and cache the value

When: I haven’t requested the value
Then: Don’t perform the operation

When: I clear the cached value
Then: requesting the value again performs the async operation again

My current solution:

    public class Cache<T> : IDisposable
        private readonly IConnectableObservable<T> _source;
        private IDisposable _connection;

        public Cache(IObservable<T> source)
            _source = Observable.Create<T>(o => source.Subscribe(o))
                                .Replay(1, Scheduler.Immediate);

        public IObservable<T> GetValue()
            return Observable.Create<T>(o =>
                                             var subscription = _source.Subscribe(o);
                                             _connection = _source.Connect();
                                             return subscription;

        public void Clear()
            if (_connection != null)
                _connection = null;

        public void Dispose()