Store segment flag on CO2 instance, not models #158
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No user impact is expected from this change.
Background: you can ask
CO2
to return segmented results by setting theresults
option to"segment"
. TheCO2
instance stores this flag for later.This changes where that flag is stored. Previously, it was stored as a public property of each model. This was unused by the model and is an unnecessary mutation.
Now, the property is stored on the
CO2
instance. I believe this is easier to follow. It should also make it possible to turn the models from stateful classes into stateless objects, simplifying the code (an idea that was discussed years ago).This new flag is explicitly marked private with the
@private
JSDoc tag and implicitly marked private by prefixing its name with an underscore; a common JS convention. (I considered using private class fields instead, but browser support is new enough that this seemed risky.)