-
-
Notifications
You must be signed in to change notification settings - Fork 36k
Allow user to abort all active requests managed by a LoadingManager. #9600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was also an inconsistency inside ImageLoader. It didn't pass its loading manager ( this.manager) to the XHRLoader created inside the load method. So the ImageLoader was calling the itemStart and itemEnd methods of its loading manager and the XHRLoader was calling the itemStart and itemEnd methods of the DefaultLoadingManager for the same call of the load method of the ImageLoader. |
9baf3a6
to
4676939
Compare
I suspect this change has side effects. It tends to be better to keep PR simple and on topic. |
I don't see what side effects it can have. The other loaders that use XHRLoader pass the loading manager. They let the XHRLoader call itemStart, itemEnd and itemError methods. Now if the load method of an ImageLoader is called these methods are called twice. This was on topic. It's not possible to elegantly abort all active requests with two LoadingManagers ( DefaultLoadingManager always used by XHRLoader when created by ImageLoader and the one passed to the ImageLoader). I think the PR is simple, just a few lines of code were modified. |
within this particular manager, right? not all requests in application? |
Yes, a loading manager can abort its active requests. Usually you don't use many loading managers in one application, but I'm open to suggestions. What do you think about the proposed solution to abort a single request (the current one of a loader)? |
it's the opposite for me, every time when user wants to load another scene, I make new manager to have common onLoad callback for all the stuff. but, if this happens before previous scene was loaded, I had to resort to hacks in order to abort it.
I did not check the code, sorry. |
I don't understand why you don't use the same loading manager. When the user wants to load another scene you just abort all the active requests and the onLoad callbacks won't be called. It seems like a clean solution to me.
I didn't write any code that enables the user to abort only a request. I just proposed to have a reference inside every loader to the current request, but I'm not sure if it is the best way to do it. Another way could be to return the request. |
which was exactly what I did in #8091 and, because I went that easier way, I could not abort from the manager. |
I think I would implement this in a different way. |
Ok, sounds good, but it should be something like scope.manager.itemStart( url, request); with request as an optional parameter. ( when we have the url in Cache we don't pass a request to itemStart ) |
I created a new commit with your instructions, but I think the name of the method abortAll is not suggestive enough. |
Um, I'm not sure |
Closing for now. This feature needs to be implemented differently if it is actually desired. |
I needed this functionality and I think others will find it useful too. The possibility to abort can also be implemented just for a request ( The active request of a Loader). To accomplish this I was thinking about keeping a reference to the current XMLHttpRequest.
Here is an example with React: