18.0.0 • Published 1 year ago
@pvway/alpha-lbs v18.0.0
AlphaLbs
This library was generated with Angular CLI version 17.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);
}
18.0.0
1 year ago
16.0.0
1 year ago
17.2.0
1 year ago
15.4.0
1 year ago
15.3.0
1 year ago
17.1.1
1 year ago
17.1.0
1 year ago
15.2.6
1 year ago
15.2.5
1 year ago
17.0.4
1 year ago
17.0.3
1 year ago
17.0.2
1 year ago
17.0.1
1 year ago
15.2.4
1 year ago
15.2.3
1 year ago
17.0.0
1 year ago
15.2.2
1 year ago
15.2.1
1 year ago
15.2.0
1 year ago
15.0.1
1 year ago