tweaking...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-11-13 13:37:10 +03:00
parent 11cf6c3cdc
commit b953fb2fe4
3 changed files with 22 additions and 8 deletions

View File

@ -2,6 +2,8 @@
*
*
*
* XXX should we have .pre/.post events???
*
**********************************************/ /* c8 ignore next 2 */
((typeof define)[0]=='u'?function(f){module.exports=f(require)}:define)
(function(require){ var module={} // make module AMD/node compatible...
@ -134,22 +136,32 @@ var eventMethod = function(name, func, options={}){
var EventHandlerMixin = {
// XXX add option to force global???
__event_handlers__: null,
on: function(evt, func){
// event...
if(evt in this){
this[evt].__event_handler_add__
&& this[evt].__event_handler_add__(this, func)
if(evt in this
&& this[evt].__event_handler_add__){
this[evt].__event_handler_add__(this, func)
// non-event...
} else {
;((this.__event_handlers__ = this.__event_handlers__ || {})[evt] =
this.__event_handlers__[evt] || [])
.push(func) }
return this },
off: function(event, func){
},
trigger: function(event, ...args){
off: function(evt, func){
// event...
if(evt in this
&& this[evt].__event_handler_add__){
this[evt].__event_handler_remove__(this, func)
// non-event...
} else {
// XXX
}
return this },
trigger: function(evt, ...args){
// XXX trigger both the context and the method event handlers...
// XXX
},
}

View File

@ -20,8 +20,9 @@ module.patchDate = require('./Date').patchDate
// Additional types...
module.containers = require('./containers')
module.runner = require('./runner')
module.generator = require('./generator')
module.event = require('./event')
module.runner = require('./runner')

View File

@ -24,6 +24,7 @@ var makeActionEvent = function(func){
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// XXX use ./event...
var Queue =
module.Queue = object.Constructor('Queue', Array, {
// create a running queue...