Results 1 to 5 of 5

Thread: [B3] Observable mixin broken?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Sep 2009
    Posts
    10
    Vote Rating
    0
      0  

    Question [B3] Observable mixin broken?

    Code:
    Ext.define('common.Connection', {
        singleton: true,
        
        mixins: {
            observable: 'Ext.util.Observable'
        },
        
        socket: null,
        
        constructor: function() {
            this.addEvents(['offline','connecting', 'online']); 
            
            Ext.onReady(Ext.bind(function() {
                this.fireEvent('connecting');
    
    
                this.socket = io.connect(null); 
                this.socket.on('error', Ext.bind(this.onError, this));
            }, this));
        },
    
    
        onError: function(reason) {
            this.fireEvent('offline', reason);
        }
    });
    This code worked perfectly in ExtJS 4.0.7, 4.1b1 and 4.1b2, but fails on ExtJS 4.1b3 in Observable.js line 444.

    Adding "hasListeners: {}" into class fixes it and everything seems working.

    A bug?

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,790
    Vote Rating
    390
      0  

    Default

    I don't think this is a bug. Try calling the mixin constructor after you call addEvents:

    Code:
    this.mixins.observable.constructor.call(this);

  3. #3
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Location
    Kansas
    Posts
    1,694
    Vote Rating
    232
      0  

    Default

    @skirtle is correct - not calling the Observable constructor was previously harmless, though bad form (one should always call a constructor).

    In 4.1b3 we've added optimizations to Observable that allow us to avoid lots of unnecessary function calls when firing events for which no one is listening. This is initialized in the Observable constructor.

    This optimization caused problems with the EventBus used by MVC applications (which is now fixed in the nightly builds).
    Don Griffin
    Director of Engineering - Frameworks (Ext JS / Sencha Touch)

    Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue

    "Use the source, Luke!"

  4. #4
    Sencha User
    Join Date
    Sep 2009
    Posts
    10
    Vote Rating
    0
      0  

    Default

    Thanks!

  5. #5
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Location
    Kansas
    Posts
    1,694
    Vote Rating
    232
      0  

    Default

    Quote Originally Posted by egorfine View Post
    Thanks!
    Thank you for digging in and reporting the problem.
    Don Griffin
    Director of Engineering - Frameworks (Ext JS / Sencha Touch)

    Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue

    "Use the source, Luke!"

Posting Permissions

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