16.0.0 • Published 2 days ago
@pvway/alpha-lbs v16.0.0
AlphaLbs
This library was generated with Angular CLI version 16.2.0.
Description
This package is a tiny local message bus service that enables components and services to communicate via publish/subscribe
Usage
We have a component or a service that will broadcast a clock object to all listening services or components.
/**
* payload : { hours: number, minutes: number, seconds: number }
*/
static readonly CLOCK_CHANNEL = AppComponent.name + 'clock_channel';
constructor(private mLbs: AlphaLbsService) { }
ngOnInit() {
setInterval(
() => {
const now = new Date();
this.mLbs.publish({
hours: now.getHours(),
minutes: now.getMinutes(),
seconds: now.getSeconds()},
AppComponent.CLOCK_CHANNEL);
}, 800);
}
We can now have another component that listens to that given channel and console.log the time
sub = -1;
constructor(private mLbs: AlphaLbsService) { }
ngOnInit(): void {
this.sub = this.mLbs.subscribe(
(clock: {hours: number, minutes: number, seconds: number}) =>
console.log(clock),
AppComponent.CLOCK_CHANNEL);
}
ngOnDestroy(): void {
this.mLbs.unsubscribe(this.sub);
}
16.0.0
2 days ago
17.2.0
4 days ago
15.4.0
4 days ago
15.3.0
10 days ago
17.1.1
10 days ago
17.1.0
11 days ago
15.2.6
13 days ago
15.2.5
18 days ago
17.0.4
20 days ago
17.0.3
20 days ago
17.0.2
20 days ago
17.0.1
1 month ago
15.2.4
1 month ago
15.2.3
2 months ago
17.0.0
2 months ago
15.2.2
2 months ago
15.2.1
2 months ago
15.2.0
2 months ago
15.0.1
2 months ago