How the API works

We provide a state of the art built-in IDE based on Microsofts VSCode to write code.

Any documents code operates within that documents scope and can not access data outside of it. At runtime the simulator will automatically flatten the document and sub document hierarchy to run the simulation in the background.

Sandbox

All user code is sandboxed for security and additionally runs in a separate thread than the app itself for performance reasons.

This means you have no access to the document global or any other globals that would allow you to escape the sandbox. A list of Supported globals can be found here.

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:

Typescript
Copy

State and Lifecycle

Let's introduce the concept of state and lifecycle in a model.

As you saw in previous code examples you can register/unregister lifecycle events via .on/.once/.off

An example:

Typescript
Copy

You will notice that the event callbacks provide a LifeCycleEventContext object. This object provides some stats about the current simulation:

Typescript
Copy
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard