I imported a class from a library that defines an event source:
class Client {
public event EventHandler<Group> GroupDiscovered;
}
If I want to use this, in C# I can just do
class Program
{
static void Main(string[] args)
{
Client client = new Client();
client.GroupDiscovered += GroupDiscovered;
}
static void GroupDiscovered(object sender, Group group)
{
Console.WriteLine($"{group.id} {group.Name}");
}
}
What’s the equivalent of this in VL? If I create a GroupDiscovered
node and feed it a Client, I get Observable<EventHandler2<Group>>
on the output. My questions:
- How do I create a function (a node?) that will be invoked when the event fires? Does this have anything to do with Delegates maybe?
- How to I attach it to the event source? As far as I understand, the GroupDiscovered node will allow me to retrieve the attached handlers from a Client instance, but how do I add a new one?