str

strapjs

Lightweight JavaScript library for OOP hackers.

Showing:

Popularity

Downloads/wk

1

Maintenance

No Maintenance Data Available

Package

Dependencies

0

Size (min+gzip)

1.8KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

strap.js

Documentation

Browser compatibility

This library is designed to be used in all modern browsers and Node.js.

Known issues

  • phantomjs not fully supported! At the moment some unit tests are failing (namespace loader) due to some strange errors with qunit and phantomjs

HelloWorld the simple way

// define the class
var Hello = class_({

    // constructor
    initialize: function(name) {
        this.name = name;
    },

    // method with your own logic
    output: function() {
        alert("Hello " + this.name + "!");
    }

});

// create instances of the the class
var instance1 = new Hello("World");
var instance2 = new Hello("strap.js");

// work with the instances
instance1.output(); // --> "Hello World!"
instance2.output(); // --> "Hello strap.js!"

// overwrite instance
instance1 = new Hello("Ninja");
instance1.output(); // --> "Hello Ninja!"

HelloWorld with namespaces

Class definition:

namespace_('strapjs.examples.helloworld', {

    HelloWorld: class_({

        // constructor
        initialize : function(name) {
            this.name = name;
        },

        // method with your own logic
        output : function() {
            alert("Hello " + this.name + "!");
        }

    })
});

Class usage:

// register the namespaces to use
var used = use_('strapjs.examples.helloworld');

// create an instance using the loader
var tst1 = used.create('HelloWorld', ['World!']);

// create an instance using the load with callback
var tst2 = used.create('HelloWorld', ['Dude!'], function(wrld2) {
    alert('callback ' + wrld2.name);
}); // --> "callback Dude!"

// create an instance without the loader but the whole namespace
var tst3 = new strapjs.examples.helloworld.HelloWorld('Ninja!');

// work with the instances
tst1.output(); // --> "Hello World!"
tst2.output(); // --> "Hello Dude!"
tst3.output(); // --> "Hello Ninja!"

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100