This project is archived and is in readonly mode.

#1068 ✓wontfix

Why is Request.onComplete fired before onFailure?

Reported by czukowski | November 5th, 2010 @ 09:38 AM | in 1.3.1 (closed)

Is there any particular reason why is Request.onComplete fired before Request.onFailure?

IMO, the onComplete event can be best used to summarize the request result, that somehow completed. onSuccess and onFailure may set some states of some objects, depending on the result. But since onComplete is called before onFailure (or onSuccess), it can't really tell what happened without looking specifically at the Request instance. Then again, if I'm going to handle response status in onComplete, the other 2 events are useless.

In other words, I can use either onComplete or onFailure and onSuccess to handle results, not all 3. I think it could be more convenient to reverse the events order so that onComplete is called last.

Comments and changes to this ticket

  • Arian

    Arian November 5th, 2010 @ 01:32 PM

    • Milestone set to 1.3.1
    • Milestone order changed from “819” to “0”
  • Arian

    Arian November 5th, 2010 @ 01:34 PM

    • Tag changed from request to oncomplete, onfailure, request
  • Christoph Pojer

    Christoph Pojer November 9th, 2010 @ 05:45 PM

    • State changed from “new” to “wontfix”
    • Assigned user set to “Christoph Pojer”

    I happen to disagree. You should not relate one event to another. The purpose of complete is to fire when a request finishes, in whatever way. To handle success and failure, there are separate events. You must never rely on the order of events.

    Complete is not meant to fire after all actions are completed but when the request actually finishes - either success or failure.

    What is your use case?

  • czukowski

    czukowski November 9th, 2010 @ 08:23 PM

    I'm using Request object to do smaller separate pieces of work, that would otherwise take too long on server side, if done in one go. I use onSuccess and onFailure to set other objects states, that would determine the next course of action and was planning on using onComplete to do some changes in user interface and advance to the next piece of work. Now I end up repeating myself and duplicating a few lines in onSuccess and onFailure, that could otherwise be in onComplete.

    You must never rely on the order of events.

    That sounds reasonably. Although if the order is documented, I see no problem with that. For instance, I can pretty much rely on that onRequest will be fired before onComplete :)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins