0.2.0 • Published 9 years ago

page-sync v0.2.0

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

page-sync NPM version

This adds sync feature to page.js.

Install

$ npm install page-sync

Usage

setup

var page = require('page');
// You can choose your favorit Promise implementation.
var Promise = require('bluebird');

var pageSync = require('page-sync')
pageSync(page, Promise);

example

you have to execute next() when every action completes.

var start = function(ctx, next) {
  console.log(ctx.path + ': start');
  next();
}

var delay = function(ctx, next) {
  console.log(ctx.path + ': delay');
  setTimeout(next, 1000);
}

var end = function(ctx, next) {
  console.log(ctx.path + ': end');
  next();
}

page('/a', start, delay, end);
page('/b', start, delay, end);

// page moves
page('/a');
page('/b');

// output
// /a: start
// /a: delay
// /a: end
// /b: start
// /b: delay
// /b: end

License

MIT