-
Notifications
You must be signed in to change notification settings - Fork 1
.exec()
hlaCk edited this page Dec 21, 2018
·
1 revision
Store and execute functions.
_z([functions]);
- _z to access UnderZ library.
- [functions] Function/s to store, MUST BE IN ARRAY.
Returns: _z(function/s) Object
_z([functions]).addThis([functions2]);
- _z to access UnderZ library.
- [functions] Store Function/s. ( MUST BE IN ARRAY )
- addThis method/action name.
- [functions2] Add function/s to stored function/s. ( you can send Function or Array of functions )
Returns: _z([functions, functions2]) Object
_z([functions]).exec( boolean );
- _z to access UnderZ library.
- [functions] Stored function/s. ( MUST BE IN ARRAY )
- exec method/action name.
- boolean true to execute, false to do nothing. default: true ( leave this blank to execute stored functions )
Returns: _z([functions]) Object
<script>
// function
function setDocTitle() {
document.title = "Way 2";
}
// create new functions store (empty)
var Myfn =_z(); // _z([])
// add function to store
Myfn.addThis(() => { console.log("Way 1"); });
// add other function to store
Myfn.addThis(setDocTitle);
// add other function to store
Myfn.addThis((function() {
this.title = "Way 3";
}).bind(document));
// add other function
Myfn.addThis( console.log.bind(console, ["way 4"]) );
Myfn.exec(false); // _z( function/s list ); no execution
Myfn.exec(); // execute all stored function/s
Myfn.last().exec(); // execute last stored function
Myfn.first().exec(false); // get first stored function
</script>Warning: If the store created like: _z(FUNCTION) the function will be executed immediately. ( MUST BE IN ARRAY )
Please read Execute function after the document is finished loading