When you subscribe to a channel in Retlang, you get an IUnsubscriber back. The equivalent of this in Rx is just IDisposable. This makes AnonymousDisposable is a fairly vital class in ReactiveExtensions. I even used it in the last post. It's a pity someone decided to mark it as internal (again). So here's another implementation of it:
public class AnonymousDisposable : IDisposable
{
private readonly Action _onDispose;
public AnonymousDisposable(Action onDispose)
{
_onDispose = onDispose;
}
public void Dispose()
{
_onDispose();
}
}