1. #1
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,340
    Vote Rating
    131
    LesJ is a name known to all LesJ is a name known to all LesJ is a name known to all LesJ is a name known to all LesJ is a name known to all LesJ is a name known to all

      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
    17,004
    Vote Rating
    650
    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
    441
    Vote Rating
    7
    wemerson.januario will become famous soon enough

      0  

    Default


    very util this method
    Wemerson Januario
    Twitter:
    @wemersonjanuar
    Skype:
    wemerson.januario
    Email: wemerson.januario@gmail.com
    Fone:
    62 9106-6689
    From: Goiânia, Brazil
    Desenvolvedor ExtJS/ ExtJS Developer

Thread Participants: 2