Skip to content
Luis Eduardo Brito edited this page Sep 4, 2013 · 4 revisions

Custom classes specialized in transferring, connecting or converting framework data (for example, a model) are encapsulated by Adapters.

Default Adapters

Creating new Adapters

An adapter don't require any special structure, you can implement them as a simple NodeJS Module and call them using the require() method.

Although, we recommend a simple class structure to organize your stuff. Use the skeleton below to implement your adapters.

var myAdapterConfig = {
    variable: "value"
}

var MyAdapter = function(config) {

    // encapsulate the class
    // public interface
    var exports = {};

    // implement a method
    function sample_method(n) {

        console.log("input: "+n);

    }; 

    // don't forget to append the function
    // to the exports variable so it can 
    // be publicly visible
    exports.sample_method = sample_method;

    // class constructor
    function init() {
        // return the public interface
        return exports;
    }

    // call the class constructor
    return init()
}
Clone this wiki locally