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?
Asked
Active
Viewed 428 times
0
-
1could you provide an example? – Simone Sanfratello Jan 25 '17 at 13:58
-
Might not need an example. I am requesting the lifecycle of events if we need to manually remove them. https://developer.mozilla.org/en/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest – Gary Jan 25 '17 at 14:10
-
2also relevant http://stackoverflow.com/a/12528067/4769440 – Daniel Lizik Jan 25 '17 at 14:46
1 Answers
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