Feature request: Lazy Values
andreisobchuck opened this issue · 4 comments
A context for a user script (variables that could be provided by an application) in an application could have high cost to calculate. But the script could be dependent only on few provided variables. We do not see a way to provide only that values that required in a script.
It would be greate feature to add a way to request a value for a variable from tweakflow runtime to host application. It could be like VariableResolver in MVEL or just a function per variable. Or it could be just ability to get list of dependent variables that referenced from a script.
Thank you for quick reaction.
We use a function to get values, but variables could be interpolated in strings, and functions can not. I understand that it's possible to declare a local variable bound to a function result. But for end-users such constructions could be tricky.
The project is great!
Regards,
Andrei.
Just pushed the ability to check whether a provided variable is referenced to master. A small example class is included. Will update docs and push a release early next week.
I've decided to expose dependency information on a Runtime.Var
as a simple boolean flag.
You can check all provided variables to see whether they are relevant or not. I could not think of a use case where lazy evaluation in the form of delayed execution through a function or class would be preferable, so I left it out.