Skip to content

Instantly share code, notes, and snippets.

@abdheshkumar
Created October 3, 2017 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abdheshkumar/f2ef0c73b942a8f5a48ec20559679105 to your computer and use it in GitHub Desktop.
Save abdheshkumar/f2ef0c73b942a8f5a48ec20559679105 to your computer and use it in GitHub Desktop.
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