Permalink
Browse files

Merge pull request #1 from distributednode/master

1) One place to edit the file to write to.
2) console log that data is read as proof that it works.
3) Removed code that should not be needed.
  • Loading branch information...
2 parents 5dd5d6f + e98d23d commit cf2cea1434fb4ca89d1ba3245a7519b68c1f7eec @minodisk committed Aug 4, 2011
Showing with 8 additions and 7 deletions.
  1. +8 −6 example/file.js
  2. +0 −1 lib/flow.js
View
@@ -2,19 +2,20 @@
var fs = require('fs');
var Flow = require('../lib/flow.js').Flow;
var now = (new Date()).toString();
+ var file = 'temp/file.txt';
// Callback style
- fs.writeFile('tmp/file.txt', now, function (err) {
+ fs.writeFile(file, now, function (err) {
if (err) {
console.log('error', err);
return;
}
- fs.readFile('tmp/file.txt', 'utf8', function (err, data) {
+ fs.readFile(file, 'utf8', function (err, data) {
if (err) {
console.log('error', err);
return;
}
- fs.unlink('tmp/file.txt', function (err) {
+ fs.unlink(file, function (err) {
if (err) {
console.log('error', err);
return;
@@ -27,13 +28,14 @@
// Flow style
var root = Flow.serial(
function (flow) {
- fs.writeFile('tmp/file.txt', now, flow.next);
+ fs.writeFile(file, now, flow.next);
},
function (flow) {
- fs.readFile('tmp/file.txt', 'utf8', flow.next);
+ fs.readFile(file, 'utf8', flow.next);
},
function (flow, data) {
- fs.unlink('tmp/file.txt', flow.next);
+ console.log(data);
+ fs.unlink(file, flow.next);
}
);
root.onError = function (err) {
View
@@ -159,7 +159,6 @@
if (++this.currentPhase < this.totalPhase) {
var actor = this._actors[this.currentPhase];
if (actor instanceof Flow) {
- actor.reset();
if (this.onError) {
actor.onError = this.onError;
}

0 comments on commit cf2cea1

Please sign in to comment.