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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ngx-intercom

v1.1.0

Published

Intercom Service provides internal communication between app components

Downloads

1,932

Readme

ngx-intercom

Intercom Service provides internal communication between app components

You can call it and use as "simplest state management", then there is no need to use NgRx / Akita / etc. or implement your own RxJs service for that. Because it's already done for you!

npm version

Install

npm i ngx-intercom --save

Import the service to your project and use it in your Component pushing new 'message' of any type intended for others components to be aware of it and reading it whenever the 'message' change in any components

Using of localStorage can be configured also to permanently save data.

import { IntercomModule } from 'ngx-intercom';

// in app.module.ts
@NgModule( {
  imports: [
    ...
    IntercomModule.forRoot({
        useLocalStorage: true, // optional, false by default
        forceUpdate: false,    // optional, false by default
    })
    ...
  ]
} )
export class AppModule { ... }

// in your first component
import { IntercomService } from 'ngx-intercom';

@Component( {
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: [ './home.component.scss' ]
} )
class HomeComponent implements OnInit {
  testMessage;

  constructor(private intercom: IntercomService){}

  ngOnInit() {
    let counter = 1;
    setInterval(() => {
      this.testMessage = `Test Message-${counter++}`;
      this.intercom.push('testMessage', this.testMessage);
      console.log(this.testMessage);
    }, 1000);

    this.intercom.push('something', 'something');

    setTimeout(() => {
       this.intercom.push('and-other-messages', 'and-other-messages');
    }, 3000);
  }

  onSomethingChange($event)
  {
    this.intercom.push('something', $event.something);
    console.log( $event.something )
  }

}

// in your other component
import { IntercomService } from 'ngx-intercom';
import { Subscription } from 'rxjs';

@Component( {
  selector: 'app-other',
  templateUrl: './other.component.html',
  styleUrls: [ './other.component.scss' ]
} )
class OtherComponent implements OnInit, OnDestroy {
  something: any;
  message: any;
  testMessage$: Observable<string>;

  private onDestroy$: Subject<void> = new Subject();

  constructor(private intercom: IntercomService){
  }

  ngOnInit() {
    // It's preferable!
    // then in .html read this way:
    // <div> {{ testMessage$ | async }} </div>
    //
    this.testMessage$ = this.intercom.read<string>('testMessage').pipe(
        pluck('testMessage'),
    );

    // ... and this way also available
    //
    this.intercom
      .read( [ 'something', 'and-other-messages' ] )
      .pipe(
          takeUntil(this.onDestroy$),
      )
      // or .read ( 'something' ) - if only one issue to be watched
      .subscribe( data => {
          if (data['something']) {
              this.something = data['something'];
          }
          if (data['and-other-messages']) {
              this.message = data['and-other-messages'];
          }
      });

  }

  onAnythingChange($event)
  {
    this.intercom.push('anything', $event.anything);
    console.log($event.anything)
  }

  ngOnDestroy(){
    this.onDestroy$.next();
  }
}

Interfaces

export interface IntercomData<T = any> {
    [key: string]: T;
}

Methods

/**
 * Push the new message / state (channel : value), 
 *  if useLocalStorage === true - localStorage will be used to store data (false by default)
 *  if forceUpdate === true - will be forcebly repeated even it's duplicate (false by default)
 */
push<T>( channel: string, value: T, useLocalStorage: boolean = false, forceUpdate: boolean = false ): void

/**
 * Read the stream of messages / state changes (channel : value), if channels are empty - read all the messages / state changes, otherwise - only specified
 */
read<T>( channels?: string | Array<string> ): Observable<IntercomData<T>>

/**
 * Read the last value of message / state by channel specified
 */
last<T>( channel: string ): T

/**
 * Remove the message / state by channel specified
 */
remove( channel: string ): boolean

Contribute

Any pull-request is more than welcome :boom: :smile:

This project adheres to the Contributor Covenant code of conduct. By participating, you are expected to uphold this code.

License

MIT