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

time param of CallbackProperty.Callback should be optional #12009

Closed
anne-gropler opened this issue May 31, 2024 · 2 comments · Fixed by #12099
Closed

time param of CallbackProperty.Callback should be optional #12009

anne-gropler opened this issue May 31, 2024 · 2 comments · Fixed by #12099

Comments

@anne-gropler
Copy link
Contributor

Feature

According to the current signature, the callback has 2 params:

  1. time, of type JulianDate
  2. result, an optional object

This implies that every CallbackProperty is time dependent. But this is not necessarily the case, as shown in this Sandcastle.

In my local app, I have the use case that sometimes, I need to get the current value of such a property elsewhere. I can do this using getValue(time), although I don't need time, so I just pass undefined instead. However, I am using Typescript strict type checking, so the ts compiler does not allow me to pass null or undefined or anything other than a JulianDate. My current workaround is to write getValue(undefined!) , which is syntactically correct, but looks confusing at best, but mostly it looks wrong.

Would it be possible to make the time parameter optional, just as the result parameter? Or would that break something?

@ggetz
Copy link
Contributor

ggetz commented Jun 4, 2024

Thanks for the suggestion @anne-gropler! I think it would be fine to mark the time parameter in the callback function signature as optional. We'd be open to review a PR.

However, I think the getValue function would at least need to define a default time to use if undefined. Otherwise, this may break existing callback function that require the time parameter.

@anne-gropler
Copy link
Contributor Author

anne-gropler commented Jul 31, 2024

We'd be open to review a PR.

I created #12099 for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment