I highly recommend that you check out Scott Kyle's 'initialize' Mutator. It
is much more generic by allowing you to add to Class.Initializers.

http://gist.github.com/100694



On Wed, Jun 3, 2009 at 4:39 AM, eskimoblood <koebe...@gmail.com> wrote:

>
> I've wrote a class mutator that load required files before initialzing
> a class. Unfortunally that works with extends. So maybe someone knows
> a way to get it work:
>
> Class.Mutators.Required = function(files){
>    return files;
> };
>
> Class.Mutators.initialize = function(initialize){
>    return function(){
>        var loaded = {}
>        $splat(this.Required).each(function(file){
>            Asset.javascript(file, {
>                onload: checkLoad.bind(this,[file, arguments])
>            });
>            loaded[file] = false;
>        }, this);
>
>        function checkLoad(file, args){
>            loaded[file] = true;
>            for (f in loaded) {
>                if (loaded[f]) {
>                    initialize.apply(this, args);
>                }
>            }
>        }
>    };
>
> };
>

Reply via email to