Results 1 to 3 of 3

Thread: Observable.fireEventArgs - why was it added in 4.2?

  1. #1
    Sencha Premium User
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,934
    Vote Rating
    548
      0  

    Default 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
    18,608
    Vote Rating
    874
      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
    Twitter - @evantrimboli

  3. #3
    Sencha Premium User wemerson.januario's Avatar
    Join Date
    Nov 2008
    Location
    Goinia - GO, Brazil
    Posts
    645
    Vote Rating
    50
      0  

    Default

    very util this method
    Wemerson Januario
    Site/Blog: http://wemersonjanuario.com.brFrom: Goinia, GO, Brazil
    Consulting Training and Web Development

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •