ig-types 6.9.5 → 6.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/event.js +11 -11
- package/main.js +1 -0
- package/package.json +1 -1
- package/test.js +7 -7
package/event.js
CHANGED
|
@@ -34,17 +34,17 @@ module.TRIGGER = module.EventCommand('TRIGGER')
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
// Create an "
|
|
37
|
+
// Create an "eventful" method...
|
|
38
38
|
//
|
|
39
39
|
// The resulting method can be either called directly or via .trigger(..).
|
|
40
40
|
// Handlrs can be bound to it via .on(..) and unbound via .off(..) and
|
|
41
41
|
// calling it will trigger the handlers either after the user func(..)
|
|
42
42
|
// return or when the user calles the passed handler(..) function.
|
|
43
43
|
//
|
|
44
|
-
//
|
|
44
|
+
// Eventful(name[, options])
|
|
45
45
|
// -> method
|
|
46
46
|
//
|
|
47
|
-
//
|
|
47
|
+
// Eventful(name, func[, options])
|
|
48
48
|
// -> method
|
|
49
49
|
//
|
|
50
50
|
//
|
|
@@ -88,9 +88,9 @@ module.TRIGGER = module.EventCommand('TRIGGER')
|
|
|
88
88
|
//
|
|
89
89
|
// NOTE: calling handle(false) will exiplicitly disable calling the
|
|
90
90
|
// handlers for that call...
|
|
91
|
-
var
|
|
92
|
-
module.
|
|
93
|
-
object.Constructor('
|
|
91
|
+
var Eventful =
|
|
92
|
+
module.Eventful =
|
|
93
|
+
object.Constructor('Eventful', {
|
|
94
94
|
|
|
95
95
|
handlerLocation: 'context',
|
|
96
96
|
|
|
@@ -189,7 +189,7 @@ object.Constructor('Eventfull', {
|
|
|
189
189
|
})
|
|
190
190
|
|
|
191
191
|
|
|
192
|
-
// Extends
|
|
192
|
+
// Extends Eventful(..) adding ability to bind events via the
|
|
193
193
|
// resulting method directly by passing it a function...
|
|
194
194
|
//
|
|
195
195
|
// Event(name[, options])
|
|
@@ -225,7 +225,7 @@ object.Constructor('Eventfull', {
|
|
|
225
225
|
// arg is a function or not...
|
|
226
226
|
var Event =
|
|
227
227
|
module.Event =
|
|
228
|
-
object.Constructor('Event',
|
|
228
|
+
object.Constructor('Event', Eventful, {
|
|
229
229
|
toString: function(){
|
|
230
230
|
return this.orig_func ?
|
|
231
231
|
'Event '
|
|
@@ -241,7 +241,7 @@ object.Constructor('Event', Eventfull, {
|
|
|
241
241
|
// call the action...
|
|
242
242
|
: object.parentCall(Event.prototype.__call__, this, context, ...args)
|
|
243
243
|
// XXX workaround for above line -- remove when fully tested...
|
|
244
|
-
//:
|
|
244
|
+
//: Eventful.prototype.__call__.call(this, context, ...args)
|
|
245
245
|
return context },
|
|
246
246
|
})
|
|
247
247
|
|
|
@@ -330,13 +330,13 @@ module.EventHandlerMixin = object.Mixin('EventHandlerMixin', {
|
|
|
330
330
|
// instead...
|
|
331
331
|
var EventDocMixin =
|
|
332
332
|
module.EventDocMixin = object.Mixin('EventDocMixin', {
|
|
333
|
-
get
|
|
333
|
+
get eventful(){
|
|
334
334
|
return object.deepKeys(this)
|
|
335
335
|
.filter(function(n){
|
|
336
336
|
// avoid triggering props...
|
|
337
337
|
return !object.values(this, n, function(){ return object.STOP }, true)[0].get
|
|
338
338
|
// XXX this is too strict...
|
|
339
|
-
&& (this[n] || {}).constructor ===
|
|
339
|
+
&& (this[n] || {}).constructor === Eventful}.bind(this)) },
|
|
340
340
|
get events(){
|
|
341
341
|
return object.deepKeys(this)
|
|
342
342
|
.filter(function(n){
|
package/main.js
CHANGED
package/package.json
CHANGED
package/test.js
CHANGED
|
@@ -381,19 +381,19 @@ Events.cases({
|
|
|
381
381
|
|
|
382
382
|
// blank events...
|
|
383
383
|
bareEventBlank: assert(
|
|
384
|
-
events.
|
|
385
|
-
'.
|
|
384
|
+
events.Eventful('bareEventBlank'),
|
|
385
|
+
'.Eventful(..): blank'),
|
|
386
386
|
eventBlank: assert(
|
|
387
387
|
events.Event('eventBlank'),
|
|
388
388
|
'.Event(..): blank'),
|
|
389
389
|
|
|
390
390
|
// normal events...
|
|
391
|
-
bareEvent: assert(events.
|
|
391
|
+
bareEvent: assert(events.Eventful('bareEvent',
|
|
392
392
|
function(handle, ...args){
|
|
393
393
|
called['bareEvent-call'] = true
|
|
394
|
-
assert(handle(), '.
|
|
394
|
+
assert(handle(), '.Eventful(..) -> handle(..)')
|
|
395
395
|
return 'bareEvent'
|
|
396
|
-
}), '.
|
|
396
|
+
}), '.Eventful(..)'),
|
|
397
397
|
event: assert(events.Event('event',
|
|
398
398
|
function(handle, ...args){
|
|
399
399
|
called['event-call'] = true
|
|
@@ -408,7 +408,7 @@ Events.cases({
|
|
|
408
408
|
|
|
409
409
|
// test event list...
|
|
410
410
|
assert.array(obj.events, ['event', 'eventBlank'], '.events')
|
|
411
|
-
assert.array(obj.
|
|
411
|
+
assert.array(obj.eventful, ['bareEvent', 'bareEventBlank'], '.eventful')
|
|
412
412
|
|
|
413
413
|
// bind...
|
|
414
414
|
var bind = function(evt){
|
|
@@ -418,7 +418,7 @@ Events.cases({
|
|
|
418
418
|
|
|
419
419
|
;['moo',
|
|
420
420
|
...obj.events,
|
|
421
|
-
...obj.
|
|
421
|
+
...obj.eventful]
|
|
422
422
|
.forEach(bind)
|
|
423
423
|
|
|
424
424
|
assert(obj.event(function(evt, ...args){
|