Results 1 to 2 of 2

Thread: Is it possible to alias mixins?

  1. #1
    Ext Premium Member
    Join Date
    Mar 2007
    Posts
    13
    Vote Rating
    0
      0  

    Default Is it possible to alias mixins?

    Hi All,

    I'm working on a project to allow remote updates of the Ext.data.Model class based from a node.js server running Ext. I've extended the Ext.util.Observable mixin into two classes: Subscriber and Publisher.

    I've defined a separate model class that would mixin the Publisher or Subscriber class based on where it's running (e.g. Publisher on the server, Subscriber on the client).

    The goal is to have the Model class not really care or be aware about which mixin it's using. This way I can swap in the behavior I need based on whether we're on the server or client, and use the same Model class for both.

    So, I'm trying to alias the mixin, e.g.

    Code:
    Ext.define("my.Model",
    {
        extend: "Ext.data.Model",
    
        mixins: 
        {
            observable: "my.Observable"
        }
    });
    And swap in the behavior based on whether I'm running on the server or the client, e.g.:

    Code:
    if (inServerEnv === true)
    {
        Ext.ClassManager.setAlias("my.Observable", "my.observable.Publisher");
    }
    else
    {
        Ext.ClassManager.setAlias("my.Observable", "my.observable.Subscriber");
    }
    But alias doesn't seem to work for mixins. Ideally I'd like the models to be (somewhat) independent of their publisher or subscriber behaviors. Any thoughts or recommendations?

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      0  

    Default

    What's wrong with using class name?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Tags for this Thread

Posting Permissions

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