scion-core
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -817,3 +817,10 @@ // Copyright 2011-2012 Jacob Beard, INFICON, and other SCION contributors | ||
} catch (e){ | ||
this._internalEventQueue.push({"name":"error.execution",data : e}); | ||
var err = { | ||
tagname: actionRef.tagname, | ||
line: actionRef.line, | ||
column: actionRef.column, | ||
reason: e.message | ||
} | ||
this._internalEventQueue.push({"name":"error.execution",data : err}); | ||
this.emit('onError', err); | ||
} | ||
@@ -1059,4 +1066,4 @@ }, | ||
/* | ||
registerListener provides a generic mechanism to subscribe to state change notifications. | ||
Can be used for logging and debugging. For example, can attache a logger that simply logs the state changes. | ||
registerListener provides a generic mechanism to subscribe to state change and runtime error notifications. | ||
Can be used for logging and debugging. For example, can attach a logger that simply logs the state changes. | ||
Or can attach a network debugging client that sends state change notifications to a debugging server. | ||
@@ -1068,3 +1075,4 @@ | ||
onExit : function(stateId){}, | ||
onTransition : function(sourceStateId,targetStatesIds[]){} | ||
onTransition : function(sourceStateId,targetStatesIds[]){}, | ||
onError: function(errorInfo){} | ||
} | ||
@@ -1079,2 +1087,3 @@ */ | ||
if(listener.onTransition) this.on('onTransition',listener.onTransition); | ||
if(listener.onError) this.on('onError', listener.onError); | ||
}, | ||
@@ -1087,2 +1096,3 @@ | ||
if(listener.onTransition) this.off('onTransition',listener.onTransition); | ||
if(listener.onError) this.off('onError', listener.onError); | ||
}, | ||
@@ -1089,0 +1099,0 @@ |
{ | ||
"name": "scion-core", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "StateCharts Interpretation and Optimization eNgine (SCION) CORE is an implementation of Statecharts in JavaScript.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -11,7 +11,7 @@ [![Build status](https://travis-ci.org/jbeard4/SCION-CORE.svg?branch=master)](https://travis-ci.org/jbeard4/SCION-CORE) | ||
SCION-CORE powers [SCION 2.0](https://github.com/jbeard4/SCION/tree/2.0.0), an implementation of [SCXML](http://www.w3.org/TR/scxml) in JavaScript, and as such, it supports all of the features of the SCXML core module, including compound states ( **OR** states), parallel states ( **AND** states), and history states. | ||
SCION-CORE powers [SCION](https://github.com/jbeard4/SCION), an implementation of [W3C SCXML](http://www.w3.org/TR/scxml) in JavaScript, and as such, it supports all of the features of the SCXML core module, including compound states ( **OR** states), parallel states ( **AND** states), and history states. | ||
# Quickstart and Simple Use Case | ||
Let's start with the simple example of drag-and-drop behaviour in the browser. You can run this demo live on jsfiddle [here](http://jsfiddle.net/jbeard4/MDkLe/2/). | ||
Let's start with the simple example of drag-and-drop behaviour in the browser. You can run this demo live on jsfiddle [here](http://jsfiddle.net/jbeard4/MDkLe/11/). | ||
@@ -219,3 +219,3 @@ An entity that can be dragged has two states: idle and dragging. If the entity is in an idle state, and it receives a mousedown event, then it starts dragging. While dragging, if it receives a mousemove event, then it changes its position. Also while dragging, when it receives a mouseup event, it returns to the idle state. | ||
npm install scion-ng | ||
npm install scion-core | ||
@@ -480,3 +480,3 @@ ## Rhino | ||
* `gen(event)`, which adds an event to the Statechart's outer queue | ||
* `send(event)`, which adds an event to the Statechart's outer queue | ||
* `raise(event)`, which adds an event to the Statechart's inner queue | ||
@@ -519,8 +519,15 @@ | ||
## sc.registerListener({onEntry : function(stateId){}, onExit : function(stateId){}, onTransition : function(sourceStateId,[targetStateIds,...]){}}) | ||
## sc.registerListener({onEntry : function(stateId){}, onExit : function(stateId){}, onTransition : function(sourceStateId,[targetStateIds,...]){}, onError: function(errorInfo){}}) | ||
Registers a callback to receive notification of state changes, as described above. | ||
Each `onEntry`, `onExit` and `onTransition` callback is optional - if the property is not present, it will be ignored. | ||
Each `onEntry`, `onExit`, `onTransition`, and `onError` callback is optional - if the property is not present, it will be ignored. | ||
The `onError` callback receives an object containing the following properties: | ||
* `tagname` - The name of the element that produced the error. | ||
* `line` - The line in the source file in which the error occurred. | ||
* `column` - The column in the source file in which the error occurred. | ||
* `reason` - An informative error message. The text is platform-specific and subject to change. | ||
# Development | ||
@@ -527,0 +534,0 @@ |
773556
214
21617
536