param
param copied to clipboard
Interaction between dynamic parameters and watching
I don't know when this might come up in a real application, but I don't think the watching mechanism is currently hooked up to work with dynamic parameters (e.g numbergen).
If I remember correctly, dynamic generates values every time you inspect a parameter (i.e __getattr__
) while watch checks for when the parameter is explicitly changed. I haven't checked, but I don't think that watch is triggered every time a dynamic value is generated (which to be consistent, I think it should)
Current applications tend to use either a pull model (param.Dynamic) or a push or subscribe model (watching), and not both, so I don't think this has come up yet. But I agree that we should connect the two approaches in this way; if something causes a new dynamic value to be created, anything watching that value should get a notification.
We probably also need some way to cause watching events when the time is changed, when appropriate. When the time changes, any Dynamic value could differ when queried, so presumably a time-changing event should also trigger an event for any watchers, for parameters that actually do change. I don't know how to achieve this in a reasonable way; seems like we'd need a global index of parameter values that might be affected. If we don't do this, seems like we need to give people guidance that clarifies that Dynamic parameters do not trigger watch events.