Add callback function to spawn.