jasonsturges Posted April 7, 2020 Share Posted April 7, 2020 How do you remove a `onComplete` handler from a shared loader? const loader = PIXI.Loader.shared; loader .add(...) .add(...) .load(); loader.onComplete.add(handler); My core application loads a standard set of textures; then, calls the complete handler. However later during runtime, new scenes can be loaded via a File -> Open operation that may contain new or custom texture assets. When I load those textures in a different area of the application via the shared loader, my original completion handler is called. This ends up chaining so that my first shared loader's `onComplete` is called twice. My workaround is to ditch the shared loader and create new instances: const loader = new PIXI.Loader(); Seems like I should be able to remove the handler, like: loader.onComplete.remove(handler); Quote Link to comment Share on other sites More sharing options...
bubamara Posted April 7, 2020 Share Posted April 7, 2020 loader.onComplete is MiniSignal. There are 3 ways how to remove handler: const binding = loader.onComplete.add(handler); loader.onComplete.detach(binding); or const binding = loader.onComplete.add(handler); binding.detach(); or detaching all at once loader.onComplete.detachAll(); Quote Link to comment Share on other sites More sharing options...
jasonsturges Posted April 9, 2020 Author Share Posted April 9, 2020 @bubamara Ah, `detach` - didn't see that for some reason. Thanks. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted April 9, 2020 Share Posted April 9, 2020 (edited) 8 minutes ago, jasonsturges said: @bubamara Ah, `detach` - didn't see that for some reason. Thanks. That's because resource-loader is in separate repo so our docs aren't usually synced up https://github.com/englercj/resource-loader it uses mini-signals, its in second circle of pixi deps, and they have detach Edited April 9, 2020 by ivan.popelyshev jasonsturges 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.