Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
dissemination
Advanced tools
Changelog
0.5.0 (2019-07-18)
Readme
Lightweight event/command library created to replace Backbone.Radio in projects ported from Backbone/Marionette to React.
npm install dissemination --save
ES6:
import dissemination from 'dissemination';
require with Node.js:
var dissemination = require('dissemination');
in browser include dist/dissemination.js
or dist/dissemination.min.js
script:
var dissemination = window.dissemination;
and then
dissemination().on('event', function() { console.log('event is fired'); });
dissemination().fire('event');
get default channel (with application
name):
const c = dissemination();
get named channel:
const c = dissemination('myChannel');
create channel directly:
import { Channel } from 'dissemination';
const c = new Channel();
add event listener:
const listener = () => { console.log('event is fired'); };
dissemination().on('event', listener);
remove specific event listener:
dissemination().off('event', listener);
remove all event listeners for a given event:
dissemination().off('event');
fire event:
dissemination().fire('event');
fire event with parameters:
const listener = params => {
console.log(params); // => { item: 1 }
};
dissemination().on('event', listener);
dissemination().fire('event', { item: 1 });
add event listener with additional options:
const listener = (params, options) => {
console.log(params); // => { item: 1 }
console.log(options); // => { message: 'hello world' }
};
dissemination().on('event', listener, {
message: 'hello world'
});
dissemination().fire('event', { item: 1 });
add event listener that will be executed once:
let count = 0;
const listener = () => { count += 1; };
dissemination().once('event', listener);
dissemination().fire('event');
dissemination().fire('event');
console.log(count); // => 1
interrupt event listeners' execution chain:
let result = 0;
const listener1 = () => { result += 1; return false; };
const listener2 = () => { result += 2; };
dissemination().on('event', listener1);
dissemination().on('event', listener2);
dissemination().fire('event');
console.log(result); // => 1
check whether event listeners are registered:
const listener = () => { console.log('event is fired'); };
dissemination().on('event', listener);
console.log(dissemination().listenersRegistered('event')); // => true
add command handler:
const handler = () => { console.log('command is handled'); };
dissemination().handle('command', handler);
remove specific command handler:
dissemination().unhandle('command');
execute command:
dissemination().execute('command');
execute command with response result:
const handler = () => { return 1 };
dissemination().handle('command', handler);
console.log(dissemination().request('command')); // => 1
add command handler with additional options:
const positive = options => options.number >= 0;
dissemination().handle('positive', positive);
console.log(dissemination().request('positive', { number: 2 })); // => true
console.log(dissemination().request('positive', { number: -1 })); // => false
check whether command handler is registered:
const handler = () => { console.log('command is handled'); };
dissemination().handle('command', handler);
console.log(dissemination().handlerRegistered('command')); // => true
add EventMixin
or/and CommandMixin
to any custom object:
import { EventMixin } from 'dissemination';
const events = Object.assign({}, EventMixin);
events.on('event', () => { console.log('event is fired'); });
events.fire('event');
import { CommandMixin } from 'dissemination';
const commands = Object.assign({}, CommandMixin);
commands.handle('command', function() { return 'hello world'; });
console.log(commands.request('command')); // => 'hello world'
In order to build library run:
npm run build
Run unit tests:
npm test
Run tests with coverage:
npm run test:coverage
In order to run tests with Coveralls locally you have to provide COVERALLS_REPO_TOKEN
:
COVERALLS_REPO_TOKEN=<token> npm run test:coverage
Before making a pull request, please, be sure that you are starting from develop
branch.
FAQs
Lightweight event/command library created to replace Backbone.Radio
The npm package dissemination receives a total of 14 weekly downloads. As such, dissemination popularity was classified as not popular.
We found that dissemination demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.