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(); } }
*clank* You’re right. The same holds true of AnonymousObserver. I’m still not very impressed with Microsoft’s love affair with static methods, though. It feels like unnecessary code hiding to me. And I note that, in their own code, they don’t call Disposable.Create.
LikeLike