Skip to content

is it possible to achieve hot module reloading in Pixi.js / Webpack #9891

Answered by zOadT
goldenratio asked this question in Q&A
Discussion options

You must be logged in to vote

Hey!

First of, I don't think there is a one fits all solution because it depends on how you prefer to structure your code (and with Pixi.js you basically have all the options) but I want to share the setup that works at least for me.

My approach is to simply swap the prototype of class instances when the class changes, so e.g. when I have a class and some instance

class A {
  update() {
    console.log(1); // (a)
  }
}

// Note, this should be done in a separate module, currently changes on Scene
// will result in additional scenes and intervals being initialised (b)
const instance = new A();
setInterval(() => instance.update(), 1000);

Now when I modify line (a) to print 2 instead of 1, i…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by goldenratio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants