Skip to content
jruizgit edited this page Jul 20, 2013 · 43 revisions

Resources

  • Basic concepts
  • Step by step
  • API reference

Sequence

var d = require('durable');   
d.run({  
  sequence: d.receive({ content: "hello world" })  
    .continueWith(function (s) { s.hello = s.getOutput().content; })  
    .checkpoint("hello")  
    .receive({ content: "good bye" })  
    .continueWith(function (s) { s.bye = s.getOutput().content; })  
    .checkpoint("bye")  
}); 

State chart

var d = require('durable');   
d.run({  
  chart: d.stateChart({
    s1: {
      t1: {
        when: d.tryReceive({ content: "s2" }),
        run: function (s) { s.i = (s.i ? s.i + 1: 1); },
        to: "s2" } },
    s2: {
      t1: {
        when: d.tryReceive({ content: "s1" }),
        run: function (s) { s.i = s.i + 1; },
        to: "s1" },
      t2: {
        when: d.tryReceive({ content: "end" }),
        to: "end" } },
    end: { } 
  }) 
});
Clone this wiki locally