Jump to content

Remove `onComplete()` handler from shared loader


Recommended Posts

How do you remove a `onComplete` handler from a shared loader?

const loader = PIXI.Loader.shared;



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:



Link to comment
Share on other sites

loader.onComplete is MiniSignal. There are 3 ways how to remove handler:

const binding = loader.onComplete.add(handler);



const binding = loader.onComplete.add(handler);


or detaching all at once



Link to comment
Share on other sites

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 by ivan.popelyshev
Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...