Injecting dependency into a class that is mixed into another?

44 views
Skip to first unread message

stephan.a...@gmail.com

unread,
Dec 18, 2014, 6:10:50 PM12/18/14
to def...@googlegroups.com
Hey, here's some pseudo code of my problem:

Ext.define('A', {

    mixins: [
        'Deft.mixin.Injectable'
    ],

    inject: [
        'xy'
    ]

    test: function() {
        xy.doSomething();
    }

}


Ext.define('B', {

    mixins: [
        'A'
    ]

}

var b = Ext.create('B');

b.test(); // FAIL

b.test() fails because xy has not been injected into A. I think this is because the Injectable hooks into 'before constructor' of the class it is applied to (A). However in this case A is mixed into B and as I understood the constructor of a mixed in class is never called. What can I do here? Or do i miss something?

Brian Kotek

unread,
Dec 18, 2014, 6:37:27 PM12/18/14
to deftjs
Hmm, I really have no idea if this will work (I've certainly never tried it). You might try manually calling the mixin constructor from the target class constructor, similar to how Ext.util.Observable works (http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.util.Observable).

--
Deft JS home page: http://deftjs.org/
Wiki: https://github.com/deftjs/DeftJS/wiki
For rules and tips on asking questions on the Deft JS mailing list: https://github.com/deftjs/DeftJS/wiki/Asking-Questions-on-the-Mailing-List
---
You received this message because you are subscribed to the Google Groups "Deft JS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to deftjs+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/deftjs/c7631925-310f-44c7-8bbc-f507f0f293f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages