boot-phase
Phase boot management with generator, use co
Last updated 2 years ago by thibremy .
MIT · Repository · Bugs · Original npm · Tarball
$ cnpm install boot-phase 
SYNC missed versions from official npm registry.

boot-phase

Phase boot management with generator, use co

import boot from './lib/';

/**
 * const b = boot();
 * Pre-phase array is not mandatory,
 * but they force phase order. 
 */
 
const b = boot([
  'start',
  'connection',
  'middleware',
]);

b.phase('start', function*() {
  console.log('start');
});

/*
* phase `new` is not defined yiet,
* this phase will be added after `middleware`.
*/
b.phase('new', function*() {
  console.log('new phase 1');
});

b.phase('start', function*() {
  console.log('start 2');
});

b.phase('connection', function*() {
  console.log('connection phase 1');
});

b.phase('connection', function*() {
  console.log('connection phase 2');
});

b.phase('middleware', function*() {
  console.log('middleware phase 1');
});

b.phase('new', function*() {
  console.log('new phase 2');
});

b.phase('start', function*(){
	console.log('start 3')
})

/*
* start generator function is not mandatory.
*/
b.start(function*() {
  console.log('final phase');
}).then(console.log('it\'s over'));
.catch(console.log('error during phase'));
/**
* Output: 
*	start phase 1
*	start phase 2
* start phase 3
*	connection phase 1
*	connection phase 2
*	middleware phase 1
* new phase 1
*/
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (2)

Copyright 2014 - 2017 © taobao.org |