page-sync

0.2.0 • Public • Published

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

Package Sidebar

Install

npm i page-sync

Weekly Downloads

3

Version

0.2.0

License

MIT

Last publish

Collaborators

  • kaminaly