What is System Runtime ?

When you code, you do not create an application, you create in fact a system.
System Runtime give you the APIs to create the model, components and behaviors of your system.

What is a system ?

A system:

  • is defined by a model,
  • is composed by components and
  • reacts to events with behaviors.

Create a system

Use System Runtime APIs to create your system:

// create a system
let system = runtime.system('system');

// add code in the start method
system.on('start', () => console.log('Hello world !'));

// start the app
system.start();

Now you can bundle your system into a JSON object:

// create a bundle
runtime.bundle();

It will return this JSON:

{
  "_id": "154cd18d0210516",
  "name": "system",
  "description": "",
  "version": "0.0.1",
  "schemas": {},
  "models": {},
  "types": {},
  "behaviors": {
    "1ea9c1d5f811ae1": {
      "_id": "1ea9c1d5f811ae1",
      "component": "154cd18d0210516",
      "state": "start",
      "action": "() => console.log('Hello world !')",
      "useCoreAPI": false,
      "core": false
    }
  },
  "components": {}
}

Install the bundle in HTML

Just add a link tag in your HTML to install and start your bundle:

<!-- import your JSON -->
<link rel="system" type="application/json" href="system.json">

<!-- load System Runtime -->
<script src="https://cdn.jsdelivr.net/npm/system-runtime@2.1.0/dist/system-runtime.min.js"></script>

Install the bundle in Node.js

Just call install and start methods to execute your bundle:

// require System Runtime
let runtime = require('system-runtime');

// install and start your system
runtime.install('system.json');

What is System Runtime ?