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

Pass js function as prop to native view #32

Closed
nick-thompson opened this issue Dec 17, 2019 · 0 comments
Closed

Pass js function as prop to native view #32

nick-thompson opened this issue Dec 17, 2019 · 0 comments
Assignees

Comments

@nick-thompson
Copy link
Collaborator

This will be some duktape/juce trickery in readVarFromDukStack inside the EcmascriptEngine implementation to check if the given stack index is a function (duk_require_function or similar), and if it is, push that function into some global stash keyed by a unique id (https://wiki.duktape.org/howtonativepersistentreferences), then construct a juce::var::NativeFunction that captures that unique ID and invokes that function from the global stash in the js environment when the constructed native function is invoked.

This will enable cleaner View callbacks (i.e. can get rid of the dispatchViewEvent hack), which will facilitate interesting components like a Canvas component who passes an onDraw function prop to native to be called back by a timer every 30-60Hz

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

No branches or pull requests

1 participant