1.1.2 • Published 8 years ago
mini-mediator v1.1.2
mini-mediator
Simple implementation of mediator pattern and observer pattern in Node.JS.
Installation
npm install mini-mediator
Usage
const Mediator = require('mini-mediator');
const mediator = new Mediator();
class MiniMath {
setMediator(mediator, done) {
this.mediator = mediator;
done();
}
calculateAdd(firstVal, secondVal) {
return firstVal + secondVal;
}
apiAdd(args, callback) {
return callback(null, this.calculateAdd(args.firstVal, args.secondVal));
}
}
class OtherComponent {
setMediator(mediator) {
this.mediator = mediator;
}
calculate5Plus3() {
this.mediator.callApi('MiniMath', 'Add', {firstVal:5, secondVal:3}, function(err, result) {
console.log(result);
});
}
}
const miniMath = new MiniMath();
const otherComponent = new OtherComponent();
mediator.register('MiniMath', miniMath);
mediator.register('OtherComponent', otherComponent);
otherComponent.calculate5Plus3();
1.1.2
8 years ago
1.1.1
8 years ago
1.1.0
8 years ago
1.0.18
8 years ago
1.0.17
8 years ago
1.0.16
8 years ago
1.0.15
8 years ago
1.0.14
8 years ago
1.0.13
8 years ago
1.0.12
8 years ago
1.0.11
8 years ago
1.0.10
8 years ago
1.0.9
8 years ago
1.0.8
8 years ago
1.0.7
8 years ago
1.0.6
8 years ago
1.0.5
8 years ago
1.0.4
8 years ago
1.0.3
8 years ago
1.0.2
8 years ago
1.0.1
8 years ago
1.0.0
8 years ago