1. #1
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,299
    Vote Rating
    109
    LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light

      0  

    Default Observable.fireEventArgs - why was it added in 4.2?

    Observable.fireEventArgs - why was it added in 4.2?


    What's the reason this new method was added? Does fireEventArgs provide better performance?

    When would I use fireEventArgs as opposed to fireEvent?

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,645
    Vote Rating
    583
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      1  

    Default


    Code:
    fireEvent: function(eventName) {
        return this.fireEventArgs(eventName, arraySlice.call(arguments, 1));
    },
    
    fireEventArgs: function(eventName, args) {
        eventName = eventName.toLowerCase();
        var me = this,
            events = me.events,
            event = events && events[eventName],
            ret = true;
    
        // Only continue firing the event if there are listeners to be informed.
        // Bubbled events will always have a listener count, so will be fired.
        if (event && me.hasListeners[eventName]) {
            ret = me.continueFireEvent(eventName, args || emptyArray, event.bubble);
        }
        return ret;
    },
    As you can see in the code, fireEvent calls fireEventArgs after pulling out the event name and casting the remaining arguments into an array. It was added for places where we're calling an event with the same arguments (think tree bubbling events).

    Edit: To elaborate

    Code:
    // Functionally equivalent
    this.fireEvent('foo', 1, 'b', 3]);
    this.fireEventArgs('foo', [1, 'b', 3]);
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User wemerson.januario's Avatar
    Join Date
    Nov 2008
    Location
    Brazil, Goias, Goiânia
    Posts
    394
    Vote Rating
    4
    wemerson.januario is on a distinguished road

      0  

    Default


    very util this method
    Wemerson Januario
    Skype:
    wemerson.januario
    Email: wemerson.januario@gmail.com
    Fone:
    62 84101145 - Goiânia-GO- Brazil
    Consulting and Training Ext JS
    Projects: (Nubes ERP)

Thread Participants: 2