0.1.8 • Published 7 years ago

loadsync v0.1.8

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

loadsync

Load and execute javascript code in web browser synchronously

Installation

(Your web fronend project should use npm to manage libraries)

$ npm install --save loadsync

Usage

Include loadsync library:

var Loadsync = require('loadsync');

Declare States and timeout:

var loadsync = new Loadsync([{
	name: 'TIMEOUT',
	cards: ['STATE1', 'STATE2', 'STATE3'],
	timeout: 500
}, {
	name: 'NO_TIMEOUT',
	cards: ['STATE3', 'STATE4', 'STATE5']
}]);

Or reset it:

// create empty loadsync instance
// var loadsync = new Loadsync();

// reset steps and begin a new flow
loadsync.reset([{
	name: 'TIMEOUT',
	cards: ['STATE1', 'STATE2', 'STATE3'],
	timeout: 500
}, {
	name: 'NO_TIMEOUT',
	cards: ['STATE3', 'STATE4', 'STATE5']
}]);

Define the ready callback function after all of states have been checked:

loadsync.ready(function(info) {
	// will be run after STATE1, STATE2, STATE3 have been checked
	// or there are some cards not be checked (timeout)
	// info.isTimeout: true/false
	// info.unchecked: list of unchecked cards
}, 'TIMEOUT');

Check each state that has been done (STATE1 for example):

loadsync.check('STATE1', 'TIMEOUT');

(the same with others: STATE2, STATE3):

loadsync.check('STATE2', 'TIMEOUT');
loadsync.check('STATE3', 'TIMEOUT');
0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago