mirror of
https://github.com/flynx/types.js.git
synced 2025-10-29 02:20:07 +00:00
added ability to overload event handler arguments...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
09d31f7ca0
commit
914dae18e1
15
event.js
15
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){
|
||||
|
||||
@ -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": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user