Using d3.carto.layer with map.refresh with d3.carto.map.
Layers made with d3.carto.layer can be defined and then added to the map and will signal their having been added with a "load" event. The layers can also be accessed with map.layers().