How to make one function wait for the answer of another that is within the first

Asked

Viewed 16 times

-1

I have my job ABAS that can only give the return when the function confirmacao within it return some value.

Could help me I’m struggling.

ABAS[submenu]["fn_afteredit_validar_leitores"] = function(ob)
{
    var msg = "";
    if(ob.value == true)
        var msg = "Deseja incluir o leitor no nível de acesso? \r\nObs.: Será realizado o envio de lista.";
    if(ob.value == false)
        var msg = "Deseja retirar o leitor do nível de acesso? \r\nObs.: Será realizado o envio de lista.";
    confirmacao(msg, function (bt)
    {
        if(bt.answer == true)
            return true;
        else
            return false;
    });
};
  • I don’t understand exactly what you want to do, a callback maybe it will, but I don’t understand what you want to do!?

  • Could you give a more detailed explanation?

1 answer

0

I wear it like this

    confirmacao(msg, function (err, bt) {
        if(err) {
         console.log('erro');
        } else {
          if(bt.answer == true)
            return true;
          else
            return false;
        }
    });
  • I guess that doesn’t answer, aside from your bt.answer return a boleano so that making a decision structure is not redundant?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.