ConstantProvider is difficult to subclass/override constants #6928
Labels
issue: docs
Describes missing or incorrect documentation
issue: feature request
Describes a new feature and why it should be added
Check for duplicates
Problem
From Mark on the forum:
It appears that the Zelos ConstantProvider (code here) sets a bunch of its constants based on this.GRID_UNIT in its constructor. Consequently, changing the value of this.GRID_UNIT after the call to super has no effect on those constants. I think that Zelos ConstantProvider should probably be changed to take the grid unit as an argument, but as a workaround until then you'll need to set all the constants that it sets explicitly in your ConstantProvider. For example:
Request
Make the ConstantProvider easier to subclass.
Allow the ConstantProvider to take a grid unit as a parameter. This can be made backwards-compatible by falling back to the class constant if no parameter is provided.
Alternatives considered
At the least, document the behavior and how to properly override these constants.
Additional context
https://groups.google.com/g/blockly/c/kiiHrcvVZoI
The text was updated successfully, but these errors were encountered: