question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request - Improve `addNodeAndEdge` utility to also bind edges to ports

See original GitHub issue

At this time, the addNodeAndEdge utility helps us easily add a new node and link it to another node while creating the edge.

export declare function addNodeAndEdge(nodes: NodeData[], edges: EdgeData[], node: NodeData, toNode?: NodeData): {
    nodes: NodeData<any>[];
    edges: EdgeData<any>[];
};

Although, if ports are configured on both nodes, it should allow us to configure ports binding too.

At this time, if ports are defined on the nodes, they aren’t being used, which generates something odd: image

In a simple use-case, where both nodes have at most 1 port per side, it should be straightforward to automatically configure binding.

The toNode is the source and should be bound by its WEST port (when Canvas direction = 'RIGHT'), while the node is the destination and should be bound by its EAST port.

Things might get more complicated when a node has several ports in the same side, but I suggest having an auto strategy that binds to the first port it finds on the side the node should be bound.

We might have a 5th argument to addNodeAndEdge, such as:

addNodeAndEdge(nodes: NodeData[], edges: EdgeData[], node: NodeData, toNode?: NodeData, portsResolver: (node: NodeData, toNode?: NodeData) => {nodePorts: PortData[], toNodePorts: PortData[]}): {
    nodes: NodeData<any>[];
    edges: EdgeData<any>[];
};

If unspecified, the 5th argument would use the default implementation, which behaves as above mentioned (binding to the first port it finds on the expected side), providing a custom portsResolver would override this behaviour and allow for more customisation.

Does this feature request makes sense? Is it something that might be added natively? I believe it would ease usage of Ports by providing a sane default behavior, while allowing for extra customisation for non-covered use-cases.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
Vadorequestcommented, Feb 25, 2021
1reaction
amcdnlcommented, Feb 9, 2021

I implemented the same in my app. It really depends on your requirements - for mine I had certain restrictions that were difficult to abstract in a way that would not make it more complicated to use. These helpers are really just starting places for common use cases - I would encourage you to make a PR to the docs in a seperate page like Advanced > Extended Helpers or something.

Read more comments on GitHub >

github_iconTop Results From Across the Web

POC with Next.js and feedback #41 - reaviz/reaflow - GitHub
Advanced utilities Feature request - Improve addNodeAndEdge utility to also bind edges to ports #47 (comment); See setEdges is undefined on ...
Read more >
Product Feature Requests - How to Write and Submit Them
A Feature Request is any suggestion for an enhancement to Qualys software. Feature Requests are not a contractual obligation for Qualys to develop...
Read more >
Feature Request - Support - VMware
If you have a suggestion for how to improve or enhance VMware software, ... Please submit your suggestions through the Feature Request form...
Read more >
Feature Request/Bug Report Form - Adobe
Welcome to the Feature Request and Bug Report Submission Form. Use this form to request new features or suggest modifications to existing features....
Read more >
Request a product feature - Articulate
Use this form to submit a feature request for our course development software and e-learning apps Articulate 360, Storyline 3, or Studio '13....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found