Creating a system in System Runtime is very simple, you do not have to code but just to define its model in a human readable format called MSON.
With MSON you can define types, classes, one to one / one to many relationships and multi inheritance between classes.
{
"firstName": "property",
"lastName": "property",
"nickname": "property",
"father": "link",
"fullName": "method"
}
Once your model is created, you will be able to get the classes of your model and create components based on your model.
Because you have defined a model for your system, a Dynamic Type Check is done on every action of your system.
// get your component class
const Jedi = runtime.require('Jedi');
// create components
const luke = new Jedi({
'firstName': 'Luke',
'lastName': 'Skywalker'
});
const anakin = new Jedi({
'firstName': 'Anakin',
'lastName': 'Skywalker'
});
// add a link
luke.father(anakin);
// get the first name of luke father
luke.father().firstName();
All your components are stored in System Runtime NoSQL Database. In fact, System Runtime acts as an ODM (Object-Document Mapper) to manage your components as NoSQL Documents.
You can find, create, update, delete components like you do in a NoSQL Database.
const Jedi = runtime.require('db')
.collections()
.Jedi;
// find components
Jedi.find({
'firstName': 'Luke'
});
// update components
Jedi.update({
'firstName': 'Anakin'
},{
'nickname': 'Darth Vader'
});
// remove components
Jedi.remove({
'firstName': 'Anakin'
});
System Runtime can bundle the model, components and methods of your system into a JSON object. This JSON can be then installed and started client-side or server-side.
In fact, System Runtime can create, install and start bundles like in OSGi.
{
"_id": "154cd18d0210516",
"name": "app",
"description": "",
"version": "0.0.1",
"schemas": {},
"models": {},
"types": {},
"behaviors": {
"1ea9c1d5f811ae1": {
"_id": "1ea9c1d5f811ae1",
"component": "154cd18d0210516",
"state": "start",
"action": "function start() {\n console.log('Hello world !');\n}",
"useCoreAPI": false,
"core": false
}
},
"components": {}
}
Just add a link tag in your HTML to install your bundle into your client-side application. You can also install your bundle on Node.js easily.
You can also install many bundles, in that case all the bundles will be composed.
<!-- on HTML -->
<link rel="system" href="system.json">
// on Node.js
const runtime = require('system-runtime');
// install and start your bundle
runtime.install('system.json');