Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Fix examples: pipes.play() is asynchronous.
  • Loading branch information
theganyo committed Feb 15, 2016
1 parent a12edf3 commit 2d1ed02
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,14 @@ var pipesConfig = {};
var pipes = bagpipes.create(pipesDefs, pipesConfig);
var pipe = pipes.getPipe('HelloWorld');

// log the output to standard out
pipe.fit(function(context, cb) {
console.log(context.output);
cb(null, context);
});

var context = {};
pipes.play(pipe, context);

console.log(context.output);
```

As you can see, the pipe in the hello world above is defined programmatically. This is perfectly ok, but
Expand All @@ -85,10 +89,14 @@ var pipesDefs = yaml.safeLoad(fs.readFileSync('HelloWorld.yaml'));
var pipes = bagpipes.create(pipesDefs, pipesConfig);
var pipe = pipes.getPipe('HelloWorld');

// log the output to standard out
pipe.fit(function(context, cb) {
console.log(context.output);
cb(null, context);
});

var context = {};
pipes.play(pipe, context);

console.log(context.output);
```

Either way, have fun!
Expand Down

0 comments on commit 2d1ed02

Please sign in to comment.