Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

External Event Handlers #2625

Open
s5bug opened this issue Feb 19, 2019 · 2 comments
Open

External Event Handlers #2625

s5bug opened this issue Feb 19, 2019 · 2 comments

Comments

@s5bug
Copy link

s5bug commented Feb 19, 2019

I'm dealing with code.org's AppLab for one of my projects. I'm using Scala and compiling to Scala.JS.

This Scala registers event handlers to AppLab's onEvent function but prepack is recognizing it as dead code.

How do I properly handle/configure this case? (There are other functions that mutate external state as well, like button, setPosition, setText that I use in my code, but I handle these with the function described in #619)

@NTillmann
Copy link
Contributor

This Scala registers event handlers to AppLab's onEvent function but prepack is recognizing it as dead code.

Do you have a small self-contained example that illustrates the issue?

@s5bug
Copy link
Author

s5bug commented Apr 10, 2019

It seems the behavior has changed now (or prepack is unable to correctly infer behavior from the ScalaJS code).

__assumeDataProperty(global, "onEvent", __abstract("function", "onEvent"));

(function() {
  onEvent("onClick", "foo", function(e) {
    console.log("hi")
  })
}).call(this);

Error on line 4.

I just recently reset my computer to free up space so I don't have a ScalaJS file to test at the moment. I'll get one as soon as time allows.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants