Skip to content

kaminaly/page-sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

This adds sync feature to page.js.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published