I have two handlers: onSuccess and onFailure, but I want sometimes (when the server decides so), to prevent either of them from running. I know I can return some ‘ignore’ from the .pipe() and to test for it within the .done() and .fail() handlers, but is there more elegant way, like tweak something in the this inside the .pipe() ?
I have two handlers: onSuccess and onFailure, but I want sometimes (when the server
Share
Could you provide more details of your case ?
When does
onFailureshould be called or not ? If your server call fails, how could you be able to know if you need to call something or nothing as you ask ?If I understand what you ask, you want to avoid to have a “if” statement in all your methods
onSuccessandonFailure. A way to do that could be to add an intermediate.pipecall and returning a new promise depending on your server answer to do something or not.