next up previous contents
Next: Introducing New HTML Tags Up: The Foreign Function Interface Previous: Writing C FFI Code   Contents

Writing JavaScript FFI Code

JavaScript is dynamically typed, so Ur/Web type definitions imply no JavaScript code. The JavaScript identifier for each FFI function is set with the jsFunc directive. Each identifier can be defined in any JavaScript file that you ask to include with the script directive.

In contrast to C FFI code, JavaScript FFI functions take no extra context argument. Their argument lists are as you would expect from their Ur types. Only functions whose ranges take the form transaction T should have side effects; the JavaScript ``return type'' of such a function is T. Here are the conventions for representing Ur values in JavaScript.

It is possible to write JavaScript FFI code that interacts with the functional-reactive structure of a document. Here is a quick summary of some of the simpler functions to use; descriptions of fancier stuff may be added later on request (and such stuff should be considered ``undocumented features'' until then).


next up previous contents
Next: Introducing New HTML Tags Up: The Foreign Function Interface Previous: Writing C FFI Code   Contents
2014-07-14