@@ -14,15 +14,15 @@ export class EventBus {
1414 /**
1515 * Gets the set of subscriptions associated with the provided http event class type.
1616 */
17- private _ensureEventSubscriptionInit < T > (
18- httpEventType : HttpEventClassType < T >
19- ) : Set < HttpEventHandler < T > > {
17+ private _ensureEventSubscriptionInit < PayloadT > (
18+ httpEventType : HttpEventClassType < PayloadT >
19+ ) : Set < HttpEventHandler < PayloadT > > {
2020 const currentEventSubscriptions = this . _subscriptions . get ( httpEventType ) ;
2121 if ( currentEventSubscriptions ) {
2222 return currentEventSubscriptions ;
2323 }
2424
25- const newEventSubscriptionsSet = new Set < HttpEventHandler < T > > ( ) ;
25+ const newEventSubscriptionsSet = new Set < HttpEventHandler < PayloadT > > ( ) ;
2626 this . _subscriptions . set ( httpEventType , newEventSubscriptionsSet ) ;
2727 return newEventSubscriptionsSet ;
2828 }
@@ -31,7 +31,7 @@ export class EventBus {
3131 * Gets the number of subscriptions for the given event.
3232 * @param {* } eventName
3333 */
34- getEventSubscriptionsCount < T > ( httpEventType : HttpEventClassType < T > ) : number {
34+ getEventSubscriptionsCount < PayloadT > ( httpEventType : HttpEventClassType < PayloadT > ) : number {
3535 const eventSubscriptions = this . _subscriptions . get ( httpEventType ) ;
3636 return eventSubscriptions ? eventSubscriptions . size : 0 ;
3737 }
@@ -41,7 +41,10 @@ export class EventBus {
4141 * @param {* } eventName
4242 * @param {* } handler
4343 */
44- subscribe < T > ( httpEventType : HttpEventClassType < T > , handler : HttpEventHandler < T > ) : ( ) => void {
44+ subscribe < PayloadT > (
45+ httpEventType : HttpEventClassType < PayloadT > ,
46+ handler : HttpEventHandler < PayloadT >
47+ ) : ( ) => void {
4548 const eventSubscriptions = this . _ensureEventSubscriptionInit ( httpEventType ) ;
4649 eventSubscriptions . add ( handler ) ;
4750
@@ -53,8 +56,8 @@ export class EventBus {
5356 * @param {* } eventName
5457 * @param {* } payload
5558 */
56- publish < T > ( httpEvent : HttpEvent < T > ) : void {
57- const httpEventType = httpEvent . constructor as HttpEventClassType < T > ;
59+ publish < PayloadT > ( httpEvent : HttpEvent < PayloadT > ) : void {
60+ const httpEventType = httpEvent . constructor as HttpEventClassType < PayloadT > ;
5861 // Do nothing if the subscriptions set for the given event is empty.
5962 const eventHandlers = this . _subscriptions . get ( httpEventType ) ;
6063 if ( ! eventHandlers || eventHandlers . size === 0 ) {
@@ -69,7 +72,10 @@ export class EventBus {
6972 * @param {* } eventName
7073 * @param {* } subscription
7174 */
72- unsubscribe < T > ( httpEventType : HttpEventClassType < T > , handler : HttpEventHandler < T > ) : void {
75+ unsubscribe < PayloadT > (
76+ httpEventType : HttpEventClassType < PayloadT > ,
77+ handler : HttpEventHandler < PayloadT >
78+ ) : void {
7379 const eventSubscriptionsSet = this . _subscriptions . get ( httpEventType ) ;
7480 if ( ! eventSubscriptionsSet || eventSubscriptionsSet . size === 0 ) {
7581 return ;
@@ -86,7 +92,7 @@ export class EventBus {
8692 * Detaches all subscriptions for the given event.
8793 * @param {* } eventName
8894 */
89- detachEventSubscriptions < T > ( httpEventType : HttpEventClassType < T > ) : void {
95+ detachEventSubscriptions < PayloadT > ( httpEventType : HttpEventClassType < PayloadT > ) : void {
9096 if ( ! this . _subscriptions . has ( httpEventType ) ) {
9197 return ;
9298 }
0 commit comments