XMLWordPrintableJSON

Details

    Description

      The current js lib uses an ajax synchronous request, which is not very typical for javascript. Since the current browsers' js are still single threaded, they block the whole website until we get an answer from the server.

      Current trunk:

      MyServiceClient.prototype.getMyObject = function (objectId) {
      this.send_getMyObject(objectId) //send request and wait for response
      return this.recv_getMyObject() //interpret response
      }

      I propose something like this: (pseudo-code + extra verbose for better understanding)

      MyServiceClient.prototype.getMyObject = function (objectId, onSuccessHandler) {
      if ( ! onSucessHandler) {
      this.send_getMyObject(objectId) //send request and wait for response
      return this.recv_getMyObject() //interpret response
      } else {
      Thrift.HttpRequest.post( send_getMyObject(objectId) ); //send request asynchronously
      Thrift.HttpRequest.onreadystatechange = function () { onSuccessHandler( this.recv_getMyObject() ); } //call handler on success
      return Thrift.HttpRequest //return request object, as user might need to attach an onError handler
      }
      }

      I think it should be something similar to the jQuery post: http://api.jquery.com/jQuery.post/
      and it will still keep the compatibility with legacy code.

      Any thoughts or ideas?

      Attachments

        1. THRIFT-1087-jquery-async-qunit.patch
          17 kB
          Henrique Mendonca
        2. THRIFT-1087-jquery-async-qunit-v2.patch
          19 kB
          Henrique Mendonca

        Activity

          People

            henrique Henrique Mendonca
            henrique Henrique Mendonca
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 168h
                168h
                Remaining:
                Remaining Estimate - 168h
                168h
                Logged:
                Time Spent - Not Specified
                Not Specified