自己动手实现jQuery Callbacks完整功能代码详解

2020-05-18 08:43:17易采站长站整理


                this.fireWith = function ( context, args )
                {
                    context = context || this;
                    _fire( context, args );
                    return this;
                };


                this.fire = function ( args )
                {
                    _fire( this, args );
                    return this;
                };


                this.lock = function ()
                {
                    _locked = true;
                    return this;
                };


                this.locked = function ()
                {
                    return _locked;
                };


            };


            // exposed to global as a factory method
            window.callbacks = function ( options )
            {
                return new Callbacks( options );
            };


        } )( window );