Skip to content

duckbox/beacon.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

##Beacon.js

Beacon is a minimal status service for processes, for example,

We make a new Beacon,

var _process = new Beacon();

We set up a function to execute when it is complete,

_process.done(function(){
	console.log('We are all done');
});

We can also listen for custom status updates,

_process.listen('stage-3', function(){
	console.log('We are at 3');
});

_process.listen('stage-7', function(){
	console.log('We are at 7');
});

A non real word example, but simple enough to explain wtf is going on,

for( i=0; i <=10; i++ ) {
		
	if( i == 3 ) {
		_process.status('stage-3');
	}
		
	if( i == 7 ) {
		_process.status('stage-7');
	}
		
}
	
_process.complete();

When the status of stage-3 is called, it would execute the listener and log "We are at 3", the same same for stage-7 and any other custom status.

When complete() is executed, our done() function executes.

Beacon.js is under 1kb and requires nothing but your browser.

About

Minimal status service for processes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published