-
Notifications
You must be signed in to change notification settings - Fork 543
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
Callback forwarding #111
Comments
From a quick glance I like Just One thing that makes it weird though is that the signal isn't two ways, so the correct way to express it maybe be edit: In those cases, one question is what would happen if you try to emit button_clicked() directly? |
About this, since you basically want to assign a function as a function property (signal handler), it could maybe be simplified further by removing parentheses too:
Or maybe:
If you ever allow native functions to be imported in the .60 file, the same syntax could be used to assign the native function directly as a signal handler instead of wrapping it with a pass-through lambda expression (if the signature allows it, the lambda at least allows adapting a callee with a slightly different signature). |
Subsequent discussion produced another angle. Signal forwarding here might serve the purpose of addressing a bigger problem: It may be desirable to write re-usable compoments in In that scenario it seems overkill to use signal forwarding and it would feel more natural if it were possible to declare that for the component in question ("Piano Key") should be able to call a function that's implemented in Rust, C++ or perhaps even JavaScript. Here's an example of a draft syntax:
The example is incomplete, but demonstrates the direction that might be worth taking instead of further encouraging the signal forwarding. |
Another possibility is to use global singleton |
With #96 being closed, i think i can close this as the solution is just to forward to a global callback. |
So, to take the earlier example from an earlier comment, this is how we can now do it:
Then in rust: application.global::<PianoLogic>().on_play_node(|note: i32| {/*... */}); |
Usually, one want to just forward a signal from the component to the parent.
Suggestions:
Perhaps the syntax could be made easier by allowing to omit the
{ }
?The text was updated successfully, but these errors were encountered: