Skip to content

Investigate using the Reflect API instead of Function in Javascript #9

Description

@LiveDuo

From https://www.reddit.com/r/rust/comments/1i0hcrt/comment/m72u90d/

One thing that irks me is that it uses the equivalent of eval() and string interpolation for very basic things, like getting a property. Wouldn't it be possible to add an API like Reflect? Especially Reflect.get() and Reflect.apply() would be super useful. Instead of

Js::invoke("console.log({})", &[e.to_string().into()])
Js::invoke("{}.textContent = 'Click'", &[button.into()])
Js::invoke("return {}[{}]", &[e.into(), "keyCode".into()])

You could write something like

Reflect::apply("console.log", &[e.to_string().into()])
Reflect::set(button, "textContent", "Click")
Reflect::get(e, "keyCode")

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions