added ability to overload event handler arguments...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-05-25 20:54:12 +03:00
parent 09d31f7ca0
commit 914dae18e1
2 changed files with 13 additions and 4 deletions

View File

@ -63,6 +63,11 @@ module.TRIGGER = module.EventCommand('TRIGGER')
// -> true
// -> false
//
// trigger event handlers and overload handler arguments...
// handle(true, ...)
// -> true
// -> false
//
// prevent event handlers from triggering...
// handle(false)
// -> undefined
@ -151,11 +156,15 @@ object.Constructor('Eventful', {
// NOTE: to explicitly disable calling the handlers func must
// call handle(false)
var did_handle = false
var handle = function(run=true){
var handle = function(run=true, ...alt_args){
did_handle = true
var a = args[0] instanceof EventCommand ?
args.slice(1)
var a = (run === true
&& arguments.length > 1) ?
alt_args
: args
a = a[0] instanceof EventCommand ?
a.slice(1)
: a
return run ?
handlers
.reduce(function(res, handler){

View File

@ -1,6 +1,6 @@
{
"name": "ig-types",
"version": "6.10.0",
"version": "6.10.1",
"description": "Generic JavaScript types and type extensions...",
"main": "main.js",
"scripts": {