Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Object-Function
Html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
Office = {
initialize: function (reason) {
$(document).ready(function () {
reason("Message from Javascript");
//Office.context.mailbox.addHandlerAsync(Office.EventType.ItemChanged, callbackfunction);
});
}
};
</script>
</head>
<body>
<script type="text/javascript" src="target/scala-2.12/cross-project-test-fastopt.js"></script>
</body>
</html>
ScalaJs:
object Main {
@js.native
@JSGlobal("Office")
object Office extends js.Any {
def initialize(f: js.Function1[String,Unit]):js.Any = js.native
}
def callback = (reason:String) => {
println(s"reason called in callback function => $reason")
}
def main(args: Array[String]): Unit = {
Office.initialize(callback)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.