Render on Demand - possible without monkey patching?

I’ve implemented a very simple render on demand plugin, kind of in the spirit of the old (but defunct) SaveCPU plugin.

I did it by monkey patching Phaser.Game.prototype.step to only run the render part if somewhere the dirty flag had been set, and the flag resets to false after rendering. See this codepen for a working example:

Using monkey patching feels dirty and brittle. Is there another, better way to achieve this?

Not possible without some core support, I think. Perhaps it could be added; I like Phaser.Game#renderPaused.

:+1:

Implementing support for pausing rendering at the Game level seems like it would be a clean solution.

I’ve initially tried to extend SceneManager states (frozen, paused) to achieve this result, but that was fraught with difficulties, because it disrupted the monotonous ordering of scene states (running > no updates > no updates and no rendering).