reactiveui/ReactiveUI — pull request #307 by xpaulbettsx (2013-05-27 01:02:53+00:00)
Title: Create Rx versions of Cocoa Delegates

This PR makes ReactiveUI.Events be Cocoa delegate aware. Note that Cocoa delegates are not at all like .NET Delegates, it's as if you took all the Events in a control and instead declared them as methods in a class.

So, given a class that looks something like this, from MonoTouch.dll:

```cs
[Model, Protocol, Register("UIAlertViewDelegate", true)]
public class UIAlertViewDelegate : NSObject
{
public virtual void Canceled(UIAlertView alertView);
public virtual void Clicked(UIAlertView alertview, int buttonIndex);
/* etc */
}
```

ReactiveUI.Events will now generate a class that looks something like this:

```cs
public class UIAlertViewDelegateRx : UIAlertViewDelegate
{
public IObservable Canceled { get; }
public IObservable> Clicked { get; }
}
```

## Caveats, there are several

* We cannot generate Observables for any non-void returning method (these methods often start with "Should..."). You can still inherit from `BlaBlaDelegateRx` and implement the Should methods if you want to, of course.
* If you combine setting `someObject.Delegate` as well as doing `someObject.Clicked += (o,e) => ...`, you will meet with disaster, as MonoTouch internally sets the Delegate to an object of its own to do events. But this is true regardless of whether you use ReactiveUI.Events or not.