Skip to content

Instantly share code, notes, and snippets.

@Ugarz
Last active March 21, 2017 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ugarz/d5ac030f20c4a0177cb57305fd339b3f to your computer and use it in GitHub Desktop.
Save Ugarz/d5ac030f20c4a0177cb57305fd339b3f to your computer and use it in GitHub Desktop.
Reflexions around module pattern in javascript

Module pattern in javascript

module.exports = (params) => {
    // create SOAP client with params
    const soapClient = easysoap.createClient(params);
    return {
        request: function(json) {
            // convert json to xml
            soapClient.call(soapXML);
        }
    }       
};

In another file use it

const params = {
    "user": "John",
    "password": "1234"
}
const clientBuilder = require('path/to/previous/code');
const client = clientBuilder(params)
client.request('')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment