Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Exporting Objects with the Exports Object in electron

//myModule.js

var MyObject = function() {

    // This is private because it is not being return
    var _privateFunction = function(param1, param2) {
        ...
        return;
    }

    var function1 = function(param1, callback) {
        ...
        callback(err, results);    
    }

    var function2 = function(param1, param2, callback) {
        ...
        callback(err, results);    
    }

    return {
        function1: function1
       ,function2: function2
    }
}();

module.exports = MyObject;
------------------------------------------------------------------------
//someFile.js

var myObject = require('myModule');

myObject.function1(param1, function(err, result) { 
    ...
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Exporting #Objects #Exports #Object #electron
ADD COMMENT
Topic
Name
4+8 =