Hybrid View

  1. #1
    Sencha User
    Join Date
    Sep 2009
    Posts
    10
    Vote Rating
    0
    egorfine is on a distinguished road

      0  

    Question [B3] Observable mixin broken?

    [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,616
    Vote Rating
    327
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      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,429
    Vote Rating
    151
    dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold

      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
    Engineering Manager - 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
    egorfine is on a distinguished road

      0  

    Default


    Thanks!

  5. #5
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Location
    Kansas
    Posts
    1,429
    Vote Rating
    151
    dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold

      0  

    Default


    Quote Originally Posted by egorfine View Post
    Thanks!
    Thank you for digging in and reporting the problem.
    Don Griffin
    Engineering Manager - 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!"

Thread Participants: 2