
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
@alwatr/signal
Advanced tools
A simple and efficient TypeScript library for event-driven communication using signals.
A simple and efficient TypeScript library for event-driven communication using signals.
untilNewNotify
method.npm install @alwatr/signal
import {AlwatrSignal} from '@alwatr/signal';
// Create a new signal
const mySignal = new AlwatrSignal<{message: string}>({name: 'my-signal'});
// Subscribe to the signal
const subscription = mySignal.subscribe((message) => {
console.log('Received message:', message);
});
// Emit an event
mySignal.notify({message: 'Hello, world!'});
// Wait for the next event asynchronously
const nextMessage = await mySignal.untilNewNotify();
console.log('Next message:', nextMessage);
// Unsubscribe when done
subscription.unsubscribe();
AlwatrSignal
constructor(config: {name: string; loggerPrefix?: string})
: Creates a new AlwatrSignal
instance.
config.name
: The name of the signal (used for logging).config.loggerPrefix
: Optional prefix for log messages.subscribe(listenerCallback: ListenerCallback<this, T>, options: SubscribeOptions = {}): SubscribeResult
: (Inherited from AlwatrObservable
) Subscribes to the signal.
listenerCallback
: The function to be called when an event is emitted.options
:
once
: If true
, the listener will be automatically unsubscribed after the first event.priority
: If true
, the listener will be executed before other listeners.receivePrevious
: If true
, the listener will be immediately called with the last emitted event (if available).disabled
: If true
, the listener will not be executed.unsubscribe(listenerCallback: ListenerCallback<this, T>)
: (Inherited from AlwatrObservable
) Unsubscribes a listener from the signal.
notify(message: T)
: Emits an event to all subscribers.
message
: The data to be sent to the subscribers.untilNewNotify()
: Returns a Promise that resolves with the next emitted event.
The following companies, organizations, and individuals support flux ongoing maintenance and development. Become a Sponsor to get your logo on our README and website.
Contributions are welcome! Please read our contribution guidelines before submitting a pull request.
This project is licensed under the AGPL-3.0 License.
FAQs
A simple and efficient TypeScript library for event-driven communication using signals.
The npm package @alwatr/signal receives a total of 180 weekly downloads. As such, @alwatr/signal popularity was classified as not popular.
We found that @alwatr/signal 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
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.