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

Considering Support Proxy? #1179

Closed
xuchiya opened this issue Feb 9, 2022 · 3 comments
Closed

Considering Support Proxy? #1179

xuchiya opened this issue Feb 9, 2022 · 3 comments

Comments

@xuchiya
Copy link

xuchiya commented Feb 9, 2022

like :
const p = new Proxy(target, handler)

@p-bakker
Copy link
Collaborator

p-bakker commented Feb 9, 2022

Duplicate of #268

@p-bakker p-bakker marked this as a duplicate of #268 Feb 9, 2022
@p-bakker p-bakker closed this as completed Feb 9, 2022
@tuchida
Copy link
Contributor

tuchida commented Feb 9, 2022

You can do something similar by implementing Scriptable.

var p = new JavaAdapter(org.mozilla.javascript.Scriptable, {
  get(name, start) {
    print(name);
    return this;
  }
});
p.aaa.bbb.ccc;
// aaa
// bbb
// ccc

@p-bakker
Copy link
Collaborator

You can do something similar by implementing Scriptable.

Note that when implementing Scriptable.get in JavaScript as suggested, that is the get impl. returns (JavaScript) undefined, the 'proxy' returns null for the gotten property. If you need it to return undefined, the get method should return org.mozilla.javascript.Undefined.SCRIPTABLE_UNDEFINED instead

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

3 participants