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

Add callable convenience functions #629

Merged
merged 2 commits into from
May 13, 2024

Conversation

chippmann
Copy link
Contributor

This adds convenience function to convert a kotlin function to a callable.
It's main use is typesafe conversion if one needs method binds.
As with godot 4, method binds are no longer in the corresponding call functions, but on a callable.
So with our binding, one needed to create a callable with string names instead of being able to use typesafe conversion functions like we provide for other things like signals.
2024-05-10T13:24:45,409946107+02:00

Now one can write code like this:

@chippmann
Copy link
Contributor Author

After brief discussion on discord i changed the convenience extension functions from being extension functions to invoke operator functions on the callable companion object. Like this, we're more in line with the regular godot constructors for callable while retaining type safety.

The new example looks like this: Callable(this, CallableMethodBindTest::readySignalMethodBindTest).bind(1, 2, 3).call()

@chippmann chippmann merged commit 71c2941 into master May 13, 2024
45 checks passed
@chippmann chippmann deleted the feature/callable_extension_helpers branch May 13, 2024 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants