Description
openedon Jul 22, 2024
Currently all of the CustomJS models essentially re-implement everything, i.e. there are many repetitions of code like
get names(): string[] {
return keys(this.args)
}
get values(): unknown[] {
return values(this.args)
}
across all of the CustomJS models, as well as other methods like _make_func
that some of the models implement but not all. Lastly the experience with actual CustomJS
is more developed, being able to accept function definitions in addition to just snippets.
I propose that all the scattered code for handling CustomJS logic be consolidated into one place so that repetition can be reduced, and behaviors can be made consistent. It seems like these days that a mixin class might be a possibility, but a compositional approach also seems reasonable. Either way, the factored out component should be responsible for:
- handling the processing of
args
- parsing and caching
Function
objects from code string property values - invoking cached functions in a consistent way
- reporting errors in a consistent way
As part of this, documentation should be updated to indicate that all CustomJS models work in the exact same way. (cf. #10794)
Activity