angular-preload-image icon indicating copy to clipboard operation
angular-preload-image copied to clipboard

Event listeners not properly cleaned up

Open nirdil opened this issue 7 years ago • 0 comments

When you create the new image in the preLoader service you attach the 'load' and 'error' event handlers. As far as I know (and tested), these listeners need to be cleaned up otherwise you'll be left with a leak. Something like this worked for me:

var preloaderImage = angular.element(new Image());
preloaderImage.on('load', function () {
      preloaderImage.off();
      successCallback();
}).on('error', function () {
      preloaderImage.off();
      errorCallback();
}).attr('src', url);

nirdil avatar Sep 20 '17 09:09 nirdil