I'm trying to create a basic force simulation with 4 nodes and 3 links. Init logic looks like this:
d3.forceSimulation(this.data.nodes).on('end', ticked(this.data));
function ticked(data) {
console.log('ticked 1');
return function () {
console.log('ticked 2');
// click listeners for nodes are created below
}
}
Now to the problem: the first log (ticked 1
) comes up almost immediately, but not the second one (ticked 2
) although it is the first line in the returned function?!
Is there an other way to properly add event listeners?