https://bugzilla.wikimedia.org/show_bug.cgi?id=23580

--- Comment #23 from Krinkle <[email protected]> ---
An updated concept, using $.Callbacks:


@@ -290,6 +290,112 @@ var mw = ( function ( $, undefined ) {

        hook: ( function () {
            var lists = {};
            return {
                /**
                 * Register a hook handler
                 */
                on: function ( name, handler ) {
                    var list = lists[name] || ( lists[name] = $.Callback(
'memory') );
                    list.add( handler );
                },
                /**
                 * Unregister a hook handler
                 */
                off: function ( name, handler ) {
                    var list = lists[name];
                    if ( list ) {
                        list.remove( handler );
                    }
                },
                /**
                 * Run a hook.
                 * @param {string} name Name of hook.
                 * @param {Mixed...} data
                 */
                emit: function ( name ) {
                    var list = lists[name] || ( lists[name] = $.Callback(
'memory') );
                    list.fireWith( null, slice.call( arguments, 1 ) );
                }
            };
        }() ),

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to