var dispatch = d3.dispatch("statechange"); dispatch.on('statechange', function(e){ console.log(e) }) setTimeout(function(){dispatch.statechange('Hello, world!')}, 3000)