-
Notifications
You must be signed in to change notification settings - Fork 584
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
Cant pass javascript functions between runtimes. #21
Comments
Well, that's interesting, and kind of weird. If you had this code in one runtime:
I'm not sure why the code is not running, I don't explicitly check for cross-runtime Object migration, though I probably should. |
I was trying to create a network of independent pieces of code, occasionally interacting with each other. My hope being that if I could export functions, that would affect code in it's origin runtime, I could define and extend the situation in pure javascript, without having to give hooks for every single function. This to create observer patterns and event triggering mechanics. I hope that is enough of an explanation. |
Thanks for the report, this was actually a pretty substantial issue with the toValue method. Basically, the reflection stuff was treating a Value as a struct, turning it into a sort of nonsensical Object in the JavaScript runtime. Your original code should work fine now. Technically, I don't think there is anything wrong with an Object existing in more than one runtime at the same time. It would be costly to try and prevent anyway (deep introspection of every value passed to toValue, etc.). |
Hello,
I've got a situation where I want multiple Otto runtimes and would like to pass functions between them to allow the runtimes to interact. But code like this doesn't work:
Doesn't make the function in the first runtime to be visible in the second. I try passing the function itself, and in Go it has the "type" [function] but the second runtime can't run the code.
Is it at all possible to make functions travel across runtimes or how can I achieve interaction between different segments of independent code? Or some sort of observer pattern and event trigger system.
The text was updated successfully, but these errors were encountered: