Question about scalajs and javascript.
How to mark a function to be purely exported to global scope?
Given scala object in top level package
@JSExport
object Foo{
def apply(a: Int, b: Int): String = "bar"+a+b
}
I would like to compile this scala code into javascript and have this function named Foo
in global scope. In other words I would like to have a javascript similar to this:
function Foo(a,b) {
return 'bar'+a+b;
}
Is it possible using scalajs?
I am writing component in javascript, which will be referenced from third party API which can not be influenced by me. This is why I simply need to follow their rules and provide javascript functions in global scope.