-
Notifications
You must be signed in to change notification settings - Fork 5
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
Event based callback signatures #15
Comments
I cannot assess whether this will render the API more developer-friendly. It's probably a good idea but it appears to me this may not be necessary. The signature for |
@galou The main goal is to make the API stable, so data passed to the api methods can change over time without breaking existing code. The evolution of FreeCAD API is unpredictable that is why I don't use inheritance (that would be easier) but metaprogramming to adapt to the changes internally while maintains a stable and documented api exposed to the extension developers. I think this change is worth to do now that not too many people uses fcapi, then when more and more extensions depend on it, it will be harder and harder to introduce changes. With this change, all methods can be implemented with one of two signatures, for example def on_execute(self):
# Valid
def on_execute(self, event):
# Valid
def on_execute(self, event: ExecuteEvent):
# Valid
|
CC @luzpaz I don't know how familiar are you with current fcapi but you have been following my previous scripting related work. Do you want to comment something about this planned change? |
CC @tomate44 |
Hi, |
With the flexible signature it makes a lot of sense. |
Thanks @mnesarco but unfortunately this is out of my purview. Maybe worth running by wwmayer ? |
I believe the change is worth to do. I will push it to the devel branch first. |
Nice, let met know when I can try out. |
@galou you can download the file from the devel branch to try it out: but documentation is still outdated. |
Hello Friends, Any comments about the proposed changes in the devel branch? I plan to go with it this week and update docs... |
Sorry, I didn't have the time to test it out. |
I will introduce a different approach here to make it more flexible so i don't have to change the signatures again in the future, I want to do this change once and only once. So I will introduce Event classes everywhere and all signatures will receive a specific Event and no more arguments. this way Event classes can be enhanced over time without breaking existing code.
Example (pseudocode):
I will introduce the same approach for everything
on_execute
,on_init
, ....This also makes signatures easier to remember.
Originally posted by @mnesarco in #2 (comment)
The text was updated successfully, but these errors were encountered: