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

JavaScript interop: method calls not working? #312

Closed
cassiel opened this issue Apr 24, 2020 · 5 comments
Closed

JavaScript interop: method calls not working? #312

cassiel opened this issue Apr 24, 2020 · 5 comments

Comments

@cassiel
Copy link

cassiel commented Apr 24, 2020

version

0.0.13-alpha.16

platform

macOS, using from Node.js.

problem

Cannot do method calls on JS objects passed in via bindings.

repro

This works (function callback):
evalString("(f)", {bindings: {f: () => console.log("HELLO")}})

This fails:
evalString("(.f foo)", {bindings: {foo: {f: () => console.log("HELLO")}}})

with: Mn [Error]: Method f on function k(a,b,c,d){this.u=a;this.A=b;this.l=c;this.C=d;this.o=16647951;this.F=139268} not allowed!

expected behavior

From the above: "HELLO".

@borkdude
Copy link
Collaborator

@cassiel For some reason the object is converted into a CLJS object. But this works:

> evalString("(.f (clj->js foo))", {classes: {allow: "all"}, bindings: {foo: {"f": () => console.log("HELLO")}}})
HELLO

I'll take a look.

borkdude added a commit that referenced this issue Apr 24, 2020
@borkdude
Copy link
Collaborator

Fixed in @borkdude/[email protected]:

> let { evalString } = require("@borkdude/sci");
undefined
> evalString("(.f foo)", {classes: {allow: "all"}, bindings: {foo: {"f": () => console.log("HELLO")}}})
HELLO

@cassiel
Copy link
Author

cassiel commented Apr 25, 2020

Fantastically fast response: thank you! (This is for interop with Cycling '74 MaxMSP for audiovisuals.) Happy to test now or wait for the NPM update.

@borkdude
Copy link
Collaborator

@cassiel The NPM library is already updated.

@cassiel
Copy link
Author

cassiel commented Apr 25, 2020

npm search still claiming alpha 13 - will fetch again. Oh, never mind, that's the version, not the alpha level.

bbss pushed a commit to bbss/sci that referenced this issue Aug 18, 2020
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

2 participants