npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ngx-signal-hub

v1.1.1

Published

[![npm version](https://badge.fury.io/js/ngx-signal-hub.svg)](https://badge.fury.io/js/ngx-signal-hub) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Downloads

74

Readme

ngx-signal-hub

npm version License: MIT

A lightweight, reactive event hub for Angular applications using Angular Signals. Enables decoupled communication with both callback-based subscriptions and Signal-based event observation.

Playground (Stackblitz)

Why ngx-signal-hub?

  • Angular Signals: Built on @angular/core/signals for reactive event handling.
  • Hybrid Approach: Supports callback-based (on, once, onCombineLatest) and Signal-based (toSignal, toSignalMultiple) event observation.
  • Automatic Cleanup: Integrates with DestroyRef for memory leak prevention.
  • Type-Safe: Strong TypeScript support with generics for event data.
  • Flexible Matching: Supports exact keys, global wildcard (*), and prefix wildcards (e.g., user:*).

Features

  • Emit events with publish(key, data).
  • Subscribe to events with on, once.
  • Observe latest events with toSignal (single key) or toSignalMultiple (multiple keys/patterns).
  • Combine multiple events with onCombineLatest.
  • Clear specific events with clearEvent(key).
  • Reset registry with reset().
  • Lightweight and Angular-native.

Installation

npm install ngx-signal-hub
# or
yarn add ngx-signal-hub

Compatibility: Requires Angular v17+ (Signals).

Usage

SignalHubService is provided in root for easy injection into components, services, or directives.

  • publish(key, data): Publishes an event, triggering subscribers and updating the registry.
  • on(options) / subscribe(options): Subscribes to events with a callback.
  • once(options): Subscribes to a single event and auto-unsubscribes.
  • onCombineLatest(options): Subscribes to multiple keys, emitting when all have values.
  • toSignal(key): Returns a Signal for the latest event of a specific key.
  • toSignalMultiple(keys, options): Returns a Signal for latest events matching multiple keys/patterns.
  • clearEvent(key): Removes a specific event from the registry.
  • reset(options): Clears the registry, optionally unsubscribing all callbacks.

Example

import { Component, DestroyRef, inject } from '@angular/core';
import { SignalHubService, HubEvent } from 'ngx-signal-hub';

interface DemoData {
  text: string;
  value: number;
}

@Component({
  selector: 'app-root',
  standalone: true,
  template: `
    <h2>Signal Hub Demo</h2>
    <button (click)="publishMessage()">Emit Message</button>
    <button (click)="publishData()">Emit Data</button>
    <hr>
    <h3>Signal Output</h3>
    <pre>Data: {{ dataSignal() | json }}</pre>
    <pre>Message: {{ messageSignal() | json }}</pre>
  `,
})
export class App {
  private hub = inject(SignalHubService);
  private destroyRef = inject(DestroyRef);

  dataSignal = this.hub.toSignal<DemoData>('data');
  messageSignal = this.hub.toSignal<string>('message');

  constructor() {
    this.hub.on<DemoData>({
      key: 'data',
      callback: (event) => console.log('Data:', event),
      destroyRef: this.destroyRef,
    });

    this.hub.once<string>({
      key: 'message',
      callback: (event) => console.log('Message (once):', event),
    });

    this.hub.on({
      key: 'data',
      callback: (event) => console.log('Data until stopped:', event),
      until: 'stop:event',
    });
  }

  publishMessage() {
    this.hub.publish('message', 'Hello World');
  }

  publishData() {
    this.hub.publish('data', { text: 'Test', value: 42 });
  }
}