joosex-meta-lazy

0.3.2 • Public • Published

Name

JooseX.Meta.Lazy - A trait to make your metaclasses lazy

SYNOPSIS

    Role("Some.Lazy.Role", {
        
        trait : JooseX.Meta.Lazy,
        
        
        has : {
            ...
        },
        
        
        methods : {
            ...
        }
    })

    Class("Some.Lazy.Class", {
        
        trait : JooseX.Meta.Lazy,
        
        does : Some.Lazy.Role
        
        
        has : {
            ...
        },
        
        
        methods : {
            ...
        }
    })
    
    // your class and role will be actually created only in this call
    var instance = new Some.Lazy.Class({
    })
    
    
    // alternative declaration - no traits required

    LazyRole("Some.Lazy.Role", {
        ...
    })

    LazyClass("Some.Lazy.Class", {
        ...
    })

INSTALLATION

From npm:

> [sudo] npm install joosex-meta-lazy         

SETUP

In NodeJS (it will export JooseX.Meta.Lazy to global scope):

require('joosex-meta-lazy')

In browsers (assuming you've completed the 3.1 item from this document):

<script type="text/javascript" src="/jsan/Task/Joose/Core.js"></script>
<script type="text/javascript" src="/jsan/JooseX/Meta/Lazy.js"></script>

DESCRIPTION

JooseX.Meta.Lazy is a meta-role, making your class (or role) lazy. "Lazy" here means, that the creation of the metaclass instance will be deferred until the first instantiation of class (or first consumption of role).

If you have a big class hierarchy (like the bridged ExtJS hierarchy for example or your own framework), this module can reduce the initialization time.

You can apply it as a trait (the 1st example in the synopsys), or you can use the new declaration helpers: LazyClass or LazyRole

INHERITANCE

Note, that by default, subclasses uses the same metaclass as their parents. Thus, if you'll subclass the lazy class, the resulting class will be also lazy. If you'd like to avoid this, see the next section for details.

eager BUILDER

If you are using the lazy metaclass and still wants to create a normal class, you can use new builder eager for that:

    Class("Some.Lazy.Class", {
        trait : JooseX.Meta.Lazy,
        
        ...
    })
    
    
    Class("Some.Eager.Class", {
        isa : Some.Lazy.Class // will provide the lazy meta for this class
        
        eager : true // will create class immediately
    })

GETTING HELP

This extension is supported via github issues tracker: http://github.com/SamuraiJack/JooseX-Meta-Lazy/issues

You can also ask questions at IRC channel : #joose

Or the mailing list: http://groups.google.com/group/joose-js

SEE ALSO

Web page of this module: http://github.com/SamuraiJack/JooseX-Meta-Lazy/

General documentation for Joose: http://joose.github.com/Joose

BUGS

All complex software has bugs lurking in it, and this module is no exception.

Please report any bugs through the web interface at http://github.com/SamuraiJack/JooseX-Meta-Lazy/issues

ACKNOWLEDGMENTS

Many thanks to Malte Ubl for the idea of this module.

AUTHORS

Nickolay Platonov nplatonov@cpan.org

COPYRIGHT AND LICENSE

Copyright (c) 2009, Nickolay Platonov

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of Nickolay Platonov nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Readme

Keywords

none

Package Sidebar

Install

npm i joosex-meta-lazy

Weekly Downloads

9

Version

0.3.2

License

none

Last publish

Collaborators

  • samuraijack