Blazor-Diagrams / Blazor.Diagrams

A fully customizable and extensible all-purpose diagrams library for Blazor
https://blazor-diagrams.zhaytam.com
MIT License
993 stars 196 forks source link

PortModel LinkAdded and LinkRemoved events don't get called #153

Closed Xuntar closed 2 years ago

Xuntar commented 2 years ago

I think there's an issue in PortModel.cs where LinkAdded and LinkRemoved are not called.

internal void AddLink(BaseLinkModel link) => _links.Add(link);

should be changed to

internal void AddLink(BaseLinkModel link)
        {
            _links.Add(link);
            LinkAdded?.Invoke(link);
        }

and the same for RemoveLink, at least if I understand the code correctly. I couldn't find any other calls to LinkAdded or LinkRemoved.

Xuntar commented 2 years ago

I'm sorry, never mind. I added the LinkAdded and LinkRemoved events myself, as I couldn't find them as referenced in the documentation (see: demos/events) where it says: "The current available events are: NodeAdded, NodeRemoved, SelectionChanged, LinkAdded, LinkAttached and LinkRemoved. I later figured out this was the Links.Added event on the Diagram, but in the meantime I had already added them myself in my version, which I forgot about, and then didn't compare the changes correctly before I logged this issue. It probably might be interesting to update the documentation though, to make it easier to find without having to check the Demo code. Thanks for the awesome project btw!