lib/chic-event.js
function (type, event) {

            // Validate arguments
            if (typeof type !== 'string') {
                throw new Error('Type must be a string');
            }

            // Check for presence of event store
            if (!this._events || !this._events[type]) { return; }

            // Get handlers
            var handlers = this._events[type];

            // Build event
            if (!(event instanceof Event)) {
                var data = event;
                event = new Event(data);
            }
            event.type = type;
            event.target = this;

            // Loop and call handlers
            var i, len = handlers.length;
            for (i = 0; i < len; i += 1) {
                handlers[i].call(this, event);

                // Prevent further handlers from being called if event is stopped
                if (event.stopped()) {
                    break;
                }
            }

        }
function (type, event) {

            // Validate arguments
            if (typeof type !== 'string') {
                throw new Error('Type must be a string');
            }

            // Check for presence of event store
            if (!this._events || !this._events[type]) { return; }

            // Get handlers
            var handlers = this._events[type];

            // Build event
            if (!(event instanceof Event)) {
                var data = event;
                event = new Event(data);
            }
            event.type = type;
            event.target = this;

            // Loop and call handlers
            var i, len = handlers.length;
            for (i = 0; i < len; i += 1) {
                handlers[i].call(this, event);

                // Prevent further handlers from being called if event is stopped
                if (event.stopped()) {
                    break;
                }
            }

        }
function ( type , event ) { // Validate arguments if ( typeof type !== 'string' ) { throw new Error ( 'Type must be a string' ) ; } // Check for presence of event store if ( ! this . _events || ! this . _events [ type ] ) { return ; } // Get handlers var handlers = this . _events [ type ] ; // Build event if ( ! ( event instanceof Event ) ) { var data = event ; event = new Event ( data ) ; } event . type = type ; event . target = this ; // Loop and call handlers var i , len = handlers . length ; for ( i = 0 ; i < len ; i += 1 ) { handlers [ i ] . call ( this , event ) ; // Prevent further handlers from being called if event is stopped if ( event . stopped ( ) ) { break ; } } }
Emit an event
Emit an event