raising jquery deferred.then () depois que todos os objetos adiados tiverem sido resolvidos

tenho duas funções javascript,save() esaveAll(), configure como abaixo:

function save(data) {
    return $.post('/save', data);
}

function saveAll(callback) {
    var dataArray = [];
    $.each(dataArray, function() {
        save(this);
    });
    callback();
}

estou interessado em modificarsaveAll() para alavancar objetos adiados por jquery e aumentar ocallback funcionar uma vez todossave() operações concluídas. no entanto, não tenho certeza da sintaxe exata ... especificamente em relação ao $ .each () dentro do $ .when (). seria algo assim?

function saveAll(callback) {
    var dataArray = [];
    $.when(
        $.each(dataArray, function() {
            return save(this);
        })
    ).then(callback);
}

questionAnswers(3)

yourAnswerToTheQuestion