Skip to content

Flags

Flags provide a way to get values from javascript when your application starts.

To start using flags, you’ll need a program defined with Browser.element, Browser.document, or Browser.application.

Then compile your program to a javascript file:

Terminal window
gren make Main --output=main.js

And create an html file that starts your program like this:

<html>
<head>
<script src="main.js"></script>
</head>
<body>
<div id="myapp"></div>
<script>
var app = Gren.Main.init({
node: document.getElementById('myapp'),
flags: Date.now()
});
</script>
</body>
</html>

In this example, the current date will be passed as the first parameter to your program’s init function.

Anything that can be trivially mapped to JSON can be used as flags. Since the 0.6.4 version of the Gren compiler, you can also pass in DataView as flags. This will be received as Bytes on the Gren end.