Skip to content

ctx.refreshScope()

ctx.refreshScope — Extensions > Layout context > Scope. Cytoscape.js signatures, parameters and return contract.

ctx.refreshScope — Extensions › Layout context › Scope

Preview · Extensions › Layout context › Scope

Read in the complete API reference · All API members

// Drop the cached scope so the next eles / nodes read the graph as it now is (118.3): a whole-graph scope is materialized once per run, and a force layout's infinite run rebuilds its sim on an add or remove
ctx.refreshScope(): void

Drop the cached scope so the next eles / nodes read the graph as it now is (118.3): a whole-graph scope is materialized once per run, and a force layout's infinite run rebuilds its sim on an add or remove. A subset scope (eles.layout()) is the caller's collection and stays what it was.

Returns void

Example

cy.layout({ impl: { run(ctx) {
cy.add({ data: { id: 'd' } });
ctx.refreshScope();
console.log(ctx.nodes.length); // 4
} } }).run();

Example graph and handle setup