Skip to content

Idiomatic way to delete selected nodes? #496

Closed Answered by perezd
perezd asked this question in Q&A
Discussion options

You must be logged in to vote

Looking through the code, I devised this solution for others who also might be wondering:

within a child component of <Svelvet> you can request the inner Graph context like so:

import { getContext } from 'svelte';
import type { Graph } from 'svelvet';
const graph = getContext<graph>('graph');

With that in hand, the graph has a groups property which is a writable store of Groups (definition here). Notice the GroupKey (definition here) can be the literal selected.

OK given that infrastructure knowledge. we can read from the store like so:

import { get } from 'svelte/store';
const nodes = get(get(graph.groups).selected.nodes);

Note that those nodes returned are yet another store see the Group

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by perezd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant