0

When I create an browser XMLHttpRequest and create event listeners like load, readystatechange, progress will they get destroyed when the XHR request completes (error/success) OR do I have to manually destroy them?

Gary
  • 2,293
  • 2
  • 25
  • 47

1 Answers1

0

Event emitters and listeners get collected like all other objects, so the xhr listeners will get collected when the "parent" xhr instance will be.

Simone Sanfratello
  • 1,520
  • 1
  • 10
  • 21
  • Ok does that mean that if - 1) I create a new XMLHttpRequest, 2) make a request, 3) create eventlisteners for all request events then >> when the XMLHttpRequest finishes with a loadend all the request events are garbage collected automatically? – Gary Jan 25 '17 at 14:59