Reputation: 1956
I have a class that has an event defined as an Action<Guid>
, as opposed to a classic EventHandler with EventArgs. Is there a way to convert this to an IObservable the same way would be done with a standard EventHandler? I need to do this so I can merge with other IObservables.
Upvotes: 0
Views: 91
Reputation: 117064
If you have this class:
public class Foo
{
public event Action<Guid> Guid;
}
Then this is the code you need to turn the non-standard event into an IObservable<Guid>
:
var foo = new Foo();
var guids = Observable.FromEvent<Guid>(
h => foo.Guid += h,
h => foo.Guid -= h);
Upvotes: 2