Hacker News new | ask | show | jobs
by BiteCode_dev 1957 days ago
That's basically what modern JS frontend frameworks do as well. I suppose as soon as something becomes too complex, keeping track of all interactions is just too complicated and rerendering the entire world efficiently looks like an easier problem to deal with.

I like the current trend of going back to renderless components as well. This way you separate the state changes from the way it looks like. Feels like each component is a miniature MVC framework with front and a back.

1 comments

> I suppose as soon as something becomes too complex, keeping track of all interactions is just too complicated and rerendering the entire world efficiently looks like an easier problem to deal with.

In fact, it can actually be less work, since you're coalescing changes into a single update() call rather than sprinkling them across observer callbacks. Also, if your update function starts running too slowly, you can always make it more precise by keeping track of which states have changed internally to the view. For example, if setting the background color takes a long time for whatever reason, you can do something like this:

    def View.update():
      if self.lightWasTurnedOn != model.lightTurnedOn:
        if model.lightTurnedOn:
          self.backgroundColor = red
        else:
          self.backgroundColor = ibmGray
        self.lightWasTurnedOn = model.lightTurnedOn
Now backgroundColor will only be set if lightTurnedOn actually changed since the last update.