nomade-factory
v0.1.0
Published
Nomade framework common factories
Downloads
3
Readme
Nomade factory
A factory repository for patterns and processes that are common in Nomade's land.
Quick start
var factory = require('nomade-factory').get('package.module');
var result = factory(/* arguments */);
// or using the create function
var result = require('nomade-factory').create('package.module', /* arguments */);
Service package
Adapter factory
Used to define services using adapter pattern.
var definition = require('nomade-factory').create(
'service.adapter', // the factory name
container, // a child container for this service
{/* adapters */}, // service adapters definitions, indexed by ID
{/* methods */} // service methods definitions, indexed by name
);
Adapters definitions should look like this:
var adapters = {
'adapter-id': {
// construct method is an optional constructor returning an engine
construct: function () { return engine; },
// each service methods must be defined, this represent the engine (if defined)
method1: function (parameter) { return this.doSomething(parameter); }
}
};
Methods definitions should look like this:
var methods = {
// all service methods are defined here
'method-name': {
// the minimal definition is the name of the method
method1: {},
// you can define a resolve method to intercept and resolve parameters
method2: { resolve: function (param1, param2) { return [param1, param2 || 'default']; }
}
};