
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
sub-events
Advanced tools
Lightweight, strongly-typed events, with monitored subscriptions.
npm i sub-events
import {SubEvent} from 'sub-events';
// creating a strongly-typed event:
const e: SubEvent<string> = new SubEvent();
// triggering the event when needed:
e.emit('hello');
// subscribing to the event:
const sub = e.subscribe((data: string) => {
// data = 'hello'
});
// cancel the subscription when no longer needed:
sub.cancel();
API: Subscription, subscribe, cancel
Class SubEventCount extends SubEvent with event onCount, to observe the number of subscriptions:
import {SubEventCount, ISubCountChange} from 'sub-events';
// creating a strongly-typed event:
const e: SubEventCount<string> = new SubEventCount();
e.onCount.subscribe((info: ISubCountChange) => {
// number of subscriptions has changed;
// info = {newCount, prevCount}
});
// any subscription will trigger event onCount:
const sub = e.subscribe(data => {});
// cancelling a subscription will trigger onCount:
sub.cancel();
API: SubEventCount, onCount
When including directly from HTML, you can access all types under subEvents
namespace:
<script src="./node_modules/sub-events/dist"></script>
<script>
const e = new subEvents.SubEvent();
e.subscribe(data => {
// data received
});
</script>
Note that pre-built script includes only the core library, without the Extras, which you can bundle yourself as needed.
FAQs
Lightweight, strongly-typed events, with monitored subscriptions.
The npm package sub-events receives a total of 5,827 weekly downloads. As such, sub-events popularity was classified as popular.
We found that sub-events demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.