mardi 23 mai 2017

Access XMLHttpRequest from Ember Data

I am developing a web application in Ember 2.3.0 and while doing some cross-browser testing, it became apparent the slowness of the application for IE 11. Doing some measurements on the IE developer's console seems that the DOM onreadystatechange event eats up to 100% CPU for a period of time, which could be a leak.

I found this article: http://ift.tt/2rdm3t3 that despite being old it encouraged me to test the approach of nulling the onreadystatechange event in case it is a memory leak.

var ajax = new XMLHttpRequest();
ajax.onreadystatechange = function () {
  if (ajax.readyState === 4) {
    // code on completion

    ajax.onreadystatechange = CollectGarbage;
    ajax = null;
  }
};

But in Ember I don't know how to access the XMLHttpRequest object directly. The JSONApiAdapter provides with an ajax method to rewrite but I don't see how I can access the raw object:

const Adapter = DS.JSONAPIAdapter.extend({
  ajax: function(){ ... }
})




Aucun commentaire:

Enregistrer un commentaire