Closed doijunior closed 5 years ago
Hi @doijunior, yes, you are right, currently reactivity support is limited although it could be extended in the future. To re-run the layout()
again, I would recommend to store the cy
instance you get in afterCreated
lifecycle hook and store a reference to it in your component's scope, this way you can invoke any method whenever is convenient for you. Let me know if that works for you.
@rcarcasses I am trying to store in a data variable like this:
afterCreated(cy) {
this.instance = cy;
}
But when I add this, the page never loads (but doesn't throw any error)
what about this?
...
<script>
...
let resolveCy = null
export const cyPromise = new Promise(resolve => (resolveCy = resolve))
// component's object
export default {
methods: {
afterCreated(cy) {
resolveCy(cy)
},
async anotherMethod() {
const cy = await cyPromise
...
}
}
...
@rcarcasses with your solution I was able to call layout()
but the problem wasnt solved because the graph was rerendered with the old names. I was able to solve it by changing the element
idalong with the name. I didn
t want to change the id
because this data is recovered from my api, then I created an id concatened with a timestamp from the last name change
I have a simple cytoscape instance like this:
My
elements
is computed array from a vuex store:When I update adding nodes and edges things work ok, but when I update only node's name the canvas don't update. I do understand that it is a limitation of the reactivity due the changes in an object attribute, but I didn't found how can I call
layout()
again