Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First go at allowing calls to Instance.evaluate in actions
- Loading branch information
David Mesquita-Morris
committed
Nov 12, 2019
1 parent
c1e0319
commit 46176e8
Showing
15 changed files
with
126 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
var state = require("../lib/node"); | ||
|
||
// create event class that a transition will respond to | ||
class MyEvent { | ||
constructor(fieldA, fieldB) { this.fieldA = fieldA; this.fieldB = fieldB; } | ||
|
||
toString() { return JSON.stringify(this); } | ||
} | ||
|
||
// log state entry, exit and trigger event evaluation | ||
state.log.add(message => console.info(message), state.log.Entry | state.log.Exit | state.log.Evaluate); | ||
|
||
// create the state machine model elements | ||
const model = new state.State("model"); | ||
const initial = new state.PseudoState("initial", model, state.PseudoStateKind.Initial); | ||
const stateA = new state.State("stateA", model); | ||
const stateB = new state.State("stateB", model).entry(() => { console.log("hellkow B") }).exit(() => { console.log("bye B") }); | ||
|
||
// HERE | ||
stateA.entry((trigger, instance) => { | ||
instance.evaluate(new MyEvent(1, 2)); | ||
}); | ||
|
||
stateA.on(MyEvent).when((e) => { return e.fieldA === 1; }).to(stateB); | ||
stateB.on(MyEvent).when((e) => { return e.fieldA === 1; }).to(stateA); | ||
// create the transition from initial pseudo state to stateA | ||
initial.to(stateA); | ||
|
||
let instance = new state.Instance("instance", model); |