I want to run some code whenever a node gets selected or deselected. I know that Node provides a selected prop through a let: directive, but due to how Svelte's let: directives work, there isn't an easy way of running some code whenever that value changes. Currently, my workaround hack is to have the following code:
<script>
function nodeSelected(value) {
// Do something here.
}
</script>
<Node let:selected ...>
{@const _ = nodeSelected(selected)}
</Node>
Node has nodeClicked and nodeReleased events, but they're not 100% the same as selected. For example, if someone selects a node by dragging a selection box around it, none of those events get fired, but the node still gets selected.
Is there a way a node can get an event when it gets selected or deselected? I'm willing to contribute a PR, but I'm asking here before spending time to code this.
I want to run some code whenever a node gets selected or deselected. I know that
Node
provides aselected
prop through alet:
directive, but due to how Svelte'slet:
directives work, there isn't an easy way of running some code whenever that value changes. Currently, my workaround hack is to have the following code:Node
hasnodeClicked
andnodeReleased
events, but they're not 100% the same asselected
. For example, if someone selects a node by dragging a selection box around it, none of those events get fired, but the node still gets selected.Is there a way a node can get an event when it gets selected or deselected? I'm willing to contribute a PR, but I'm asking here before spending time to code this.