Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
A simple pub/sub written in Typescript
import { Subscription } from '../dist';
const mySub = Subscription.create<number>();
const unsub = mySub.subscribe(num => {
console.log('num: ' + name);
});
mySub.call(45); // num: 45
unsub();
Take a look at the Examples folder.
Create a new Subscription
options.onFirstSubscription?
: A function called when the subscriber count goes from 0 to 1options.onLastUnsubscribe?
: A function called when the subscriber count goes from 1 to 0Note: by default the T
type is void
meaning the Subscription
has no data.
A subscription object
Add a subscriber
subId
(optional): Associate an id with the listener to be able to unsubscribe
by this same id.listener
: The function that will be called when you call
, this function receive a value as parameter (of type T
)Unsubscribe
: returns a function that will unsubscribe the listener.Call all listeners in the same order they were subscribed
value
: The value (of type T
) that will be passed to the listenersNote: If T
is void
this function does not take any arguments.
Unsubscribe all listeners
Unsubscribe a listener either by reference or by id
listener
: Either an id (string
) or a reference to a listenerTest wether a listener id subscribed or not
listener
: Either an id (string
) or a reference to a listenerFAQs
A simple pub/sub written in Typescript
The npm package suub receives a total of 7 weekly downloads. As such, suub popularity was classified as not popular.
We found that suub 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
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.