NGX BROADCASTER LIBRARY
NGX BROADCASTER is a library that provides the service for Angular applications to access global emitted events from components, service etc..
Installation
npm install ngx-broadcaster
Refer NPM package here.
Usage
import { NgBroadcasterModule } from 'ngx-broadcaster';
@NgModule({
declarations: [
AppComponent,
SampleComponent
],
imports: [
BrowserModule,
NgBroadcasterModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Example
Sample.component.html
Send Message
Sample.component.ts
// Selector : app-component constructorprivate broadcaster:NgBroadcasterService ngOnInit sendMessage
App.component.html
<h1>{{message}}</h1>
<br>
<app-sample></app-sample>
App.component.ts
public message:string; constructorprivate broadcaster:NgBroadcasterService ngOnInit
API Reference
Event Payload Interface
export interface EventPayload{
eventName:string;
eventData:any;
}
License
This project is licensed under the terms of the MIT license.
Further help
If you have ideas for more that should be on this page, let me know