Local events can be emitted only between mesh components in the same node. These events do not reach clients or go over the network.
These events use the standard node EventEmitter
and do not support wildcards.
Component1.prototype.makeSomethingHappen = function ($happn, callback) {
$happn.localEventEmitter.emit('something/happened', {data: 1});
callback();
};
Component2.prototype.start = function ($happn, callback) {
// subscribe
$happner.localEvent.component1.on(
'something/happened', this.eventHandler = function (data) {
});
callback();
};
Component2.prototype.stop = function ($happn, callback) {
// unsubscribe
$happn.localEvent.component1.removeListener('something/happened', this.eventHandler);
callback();
};
The same subscription api is also available in the server as resolved at create()
.
Happner.create(config)
.then(function (server) {
server.localEvent...
});