From 914dae18e1649b71c51d0ff93ecfa997ca4a30ad Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 25 May 2022 20:54:12 +0300 Subject: [PATCH] added ability to overload event handler arguments... Signed-off-by: Alex A. Naanou --- event.js | 15 ++++++++++++--- package.json | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/event.js b/event.js index 6f5c426..2a54bad 100644 --- a/event.js +++ b/event.js @@ -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){ diff --git a/package.json b/package.json index b0b6a64..c426a02 100644 --- a/package.json +++ b/package.json @@ -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": {