How the API works
Flux has a built-in code editor to write code.

The code of a document runs in the scope of that document. It cannot access data outside the document. At runtime, the simulator flattens the document and subdocument hierarchy and runs the simulation in the background.
Sandbox
Flux runs all user code in a sandbox for security. For performance, the code runs in a thread that is separate from the app.
Your code has no access to the document global or to other globals that can escape the sandbox. For the globals that your code can use, see Supported globals.
Flux Global Object
Most of the model API is accessible from Flux global object. This includes functions to create nodes, access the nodes, show notifications, and much more. For example:
State and Lifecycle
A model has state and a lifecycle.
To register and unregister callbacks for lifecycle events, use flux.on, flux.once, and flux.off.
Example:
Each event callback receives a LifeCycleEventContext object. This object gives data about the current simulation: