Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
draht provides process-level messaging.
$ npm install draht
The first thing you need to do is to integrate draht into your application. For that add a reference to the draht
module.
const draht = require('draht');
To access the global draht, you need to call the get
function.
const bus = draht.get();
Each time you call the get
function, you get the very same instance of the draht.
If you need your own draht channel, call the create
function.
const bus = draht.create();
Each time you call the create
function, you get a new draht instance.
To emit an event, call the draht's emit
function and provide the event name as well as its payload as parameters. Optionally, you may specify a callback.
bus.emit('foo', { bar: 'baz' }, () => {
// ...
});
Please note that the emit
function internally calls process.nextTick
to make sure that an event is processed asynchronously.
You can also emit namespaced events. For that, prefix the event name with the namespace name and separate them by using the expression ::
.
bus.emit('demo::foo', { bar: 'baz' }, () => {
// ...
});
To subscribe to an event, call the on
function and provide the name of the event you want to subscribe to as well as an event handling function.
bus.on('demo::foo', (evt, callback) => {
// ...
});
Alternatively you may also use the once
function to subscribe to an event and have the handler automatically removed afterwards.
bus.once('demo::foo', (evt, callback) => {
// ...
});
If you want to receive all events within a specific namespace, you can use the *
character.
bus.on('demo::*', (evt, callback) => {
// ...
});
Nested namespaces are supported as well, but please note that when using wildcards you need to specify them for each namespace level separately. E.g., if you have events in the form foo::bar::baz
and you would like to subscribe to any event in the foo
namespace, use foo::*::*
, not foo::*
.
From time to time you need to unsubscribe from an event. For this use the removeListener
function and provide the event name as well as the handler to remove. Please note that in this case you need to provide the very same handler instance to removeListener
as you previously used.
const onFoo = function (evt, callback) {
// ...
};
bus.on('demo::foo', onFoo);
// ...
bus.removeListener('demo::foo', onFoo);
To remove all listeners for an event use removeAllListeners
and provide only the event name.
bus.removeAllListeners('demo::foo');
If you omit the event name, too, then all listeners for all events are unsubscribed.
bus.removeAllListeners();
To build this module use roboter.
$ bot
The MIT License (MIT) Copyright (c) 2013-2017 the native web.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
draht provides process-level messaging.
The npm package draht receives a total of 20,665 weekly downloads. As such, draht popularity was classified as popular.
We found that draht demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.