UNPKG

1.93 kBMarkdownView Raw
1# Overview
2
3SCION is an industrial-strength implementation of [W3C SCXML](http://www.w3.org/TR/scxml/) in JavaScript.
4
5SCXML provides a declarative markup for Statecharts, a powerful modelling language for developing **complex, timed, event-driven, state-based systems**.
6
7# Installation
8
9## node.js
10
11`npm install scxml`
12
13## browser
14
15`bower install jbeard4/scion`
16
17Or add:
18
19`<script src="https://cdnjs.cloudflare.com/ajax/libs/scion/3.0.2/scxml.min.js">`
20
21# Quickstart
22
23```javascript
24scxml.urlToModel("drag-and-drop.xml",function(err,model){
25
26 if(err) throw err;
27
28 model.prepare(function(err, fnModel) {
29
30 if(err) throw err;
31
32 //instantiate the interpreter
33 var sc = new scxml.scion.Statechart(fnModel);
34
35 //start the interpreter
36 sc.start();
37
38 //send the init event
39 sc.gen({name:"init",data:rect});
40
41 });
42})
43```
44
45# API
46
47## Instantiation
48
49### scxml.urlToModel(url,function(err, model){} [, context])
50### scxml.pathToModel(path,function(err, model){} [, context])
51### scxml.documentStringToModel(url,scxmlDocString,function(err, model){} [, context])
52### scxml.documentToModel(scxmlDocument,function(err, model){} [, context])
53
54Compile SCXML to JavaScript object "model".
55
56### model.prepare(function(err, fnModel) {}, executionContext, hostContext)
57
58Prepare the model by downloading source scripts and constructing a host execution context for the SCXML datamodel.
59
60### new scxml.scion.Statechart(fnModel, options)
61
62
63The Statechart constructor creates an interpreter instance from a model object.
64
65```javascript
66 //same model can be used to create multiple interpreter instances
67 var sc1 = new scxml.scion.Statechart(fnModel),
68 sc2 = new scxml.scion.Statechart(fnModel);
69```
70
71## Statechart Interpreter API
72
73See [SCION-CORE API](https://github.com/jbeard4/SCION-CORE#api).
74
75
76# Build Status
77
78[![Build status](https://travis-ci.org/jbeard4/SCION.svg)](https://travis-ci.org/jbeard4/SCION)
79