Uploaded image for project: 'Moodle app'
  1. Moodle app
  2. MOBILE-1592

Check if a WS call is running and return the ongoing promise if it is

    XMLWordPrintable

Details

    • Hide

      Run the following code in console and check that both "Success" are written to console. Go to Network tab and check that only 1 request was done.

      var $mmSite = angular.element(document.querySelector('[ng-app]')).injector().get('$mmSite'),
          data = {userid: $mmSite.getUserId()},
          preSets = {getFromCache: false};
       
      $mmSite.read('core_enrol_get_users_courses', data, preSets).then(function(courses) {
          console.log('Success', courses.length);
      });
      $mmSite.read('core_enrol_get_users_courses', data, preSets).then(function(courses) {
          console.log('Success', courses.length);
      });
      

      Execute it again to see the request is done again.

      Run the following code in console and check that two heads are retrieved only once with different result:

      var $mmWS = angular.element(document.querySelector('[ng-app]')).injector().get('$mmWS');
      $mmWS.getRemoteFileSize('http://i.telegraph.co.uk/multimedia/archive/03589/Wellcome_Image_Awa_3589699k.jpg').then(function(data) {
          console.log('FileSize ' + data);
      });
      $mmWS.getRemoteFileMimeType('http://i.telegraph.co.uk/multimedia/archive/03589/Wellcome_Image_Awa_3589699k.jpg').then(function(data) {
          console.log('MimeType ' + data);
      });
      

      Show
      Run the following code in console and check that both "Success" are written to console. Go to Network tab and check that only 1 request was done. var $mmSite = angular.element(document.querySelector('[ng-app]')).injector().get('$mmSite'), data = {userid: $mmSite.getUserId()}, preSets = {getFromCache: false};   $mmSite.read('core_enrol_get_users_courses', data, preSets).then(function(courses) { console.log('Success', courses.length); }); $mmSite.read('core_enrol_get_users_courses', data, preSets).then(function(courses) { console.log('Success', courses.length); }); Execute it again to see the request is done again. Run the following code in console and check that two heads are retrieved only once with different result: var $mmWS = angular.element(document.querySelector('[ng-app]')).injector().get('$mmWS'); $mmWS.getRemoteFileSize('http://i.telegraph.co.uk/multimedia/archive/03589/Wellcome_Image_Awa_3589699k.jpg').then(function(data) { console.log('FileSize ' + data); }); $mmWS.getRemoteFileMimeType('http://i.telegraph.co.uk/multimedia/archive/03589/Wellcome_Image_Awa_3589699k.jpg').then(function(data) { console.log('MimeType ' + data); });
    • Moderate
    • MOODLE_31_STABLE
    • MOODLE_31_STABLE
    • Medium

    Description

      If the a WS call with same arguments is called twice the mmWS library will check it twice.

      We should implement a ongoing promises list and return it instead of launch it again.

      Attachments

        Activity

          People

            pferre22 Pau Ferrer
            pferre22 Pau Ferrer
            Dani Palou Dani Palou
            Juan Leyva Juan Leyva
            Juan Leyva Juan Leyva
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 3 days, 1 hour, 30 minutes
                3d 1h 30m
                Remaining:
                0m
                Logged:
                Time Not Required
                Not Specified

                Clockify

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.