Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[internal] on demand pure functions #246

Open
dbuezas opened this issue Feb 7, 2023 · 1 comment
Open

[internal] on demand pure functions #246

dbuezas opened this issue Feb 7, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@dbuezas
Copy link
Owner

dbuezas commented Feb 7, 2023

Describe the solution you'd like
Users may want to change attributes like texttemplate or hovertemplate and still make them depend on other defaulted props (e.g unit_of_measurement) which are also funcitons.
This breaks the delicate order of evaluation and results in an error like "this fn can't use this param because it is also a fn and it should be defined before".

To work around that: implement pure functions for internal use of the defaults. These should have no side effects (not modify any parameter, like vars), which will allow to safely call them on demand (even if defined later)
With that

Additional context
I tried it once and it worked, but dropped it because the code got kind of messy. I think it would be best if the functions are also ensured to be called only once by adding it to the incrementally parsed config once evaluated. Ideally pure functions should be available to users for corner cases, but not documented to discourage their usage as they are a somewhat complex/unintuitive/brittle concept.

@dbuezas dbuezas added the enhancement New feature or request label Feb 7, 2023
@dbuezas dbuezas changed the title [internal] [internal] on demand pure functions Feb 7, 2023
@dbuezas
Copy link
Owner Author

dbuezas commented Feb 10, 2023

Actual failure case example in #243

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant