make rule-value-function and global work together #1427
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.
Fix #1335
Implementation details
I attach an attribute
updateFun
to rules with type'global'
that have a function as declaration (i.e. rules that match both plugins).I already had to modify
RuleList.js
to prevent the special caserule.rules instanceof RuleList
from skipping the update, so I included the code that executesupdateFun
inRuleList.js
. An important choice (that is easily modifiable) is thatplugins.onUpdate
will not be launched on the global rule that is updated with a function: other plugins will not run on the updated properties.Another meaningful possibility would be to include the call to
updateFun
in theonUpdate
method of therule-value-function
. This would allow us to callplugins.onUpdate
fromRuleList.js
, so have other plugins run on the rule after update. I was not sure what interactions this could create with other plugins so I didn't handle it this way.It is my first contribution to a JS project, so please feel free to give me advice to improve my coding style 馃槂
Example
gives