File

lib/shared/modules/messages-broker/messages-broker.types.ts

Description

Interface defining the contract for message brokering.

Index

Methods

Methods

emit
emit(chanel: string, data: T)
Type parameters :
  • T

Emits a message to a specific channel.

Parameters :
Name Type Optional Description
chanel string No
  • The channel to emit the message to.
data T No
  • The data to emit.
Returns : Promise<void>
subscribe
subscribe(chanel: string, handler: (data: T) => void)
Type parameters :
  • T

Subscribes to a specific channel with a handler function.

Parameters :
Name Type Optional Description
chanel string No
  • The channel to subscribe to.
handler function No
  • The handler function to handle the data.
Returns : any
unsubscribe
unsubscribe(chanel: string)

Unsubscribes from a specific channel.

Parameters :
Name Type Optional Description
chanel string No
  • The channel to unsubscribe from.
Returns : any
export interface MessagesBroker {
  /**
   * Emits a message to a specific channel.
   * @param chanel - The channel to emit the message to.
   * @param data - The data to emit.
   */
  emit<T = unknown>(chanel: string, data: T): Promise<void>;

  /**
   * Subscribes to a specific channel with a handler function.
   * @param chanel - The channel to subscribe to.
   * @param handler - The handler function to handle the data.
   */
  subscribe<T = unknown>(chanel: string, handler: (data: T) => void);

  /**
   * Unsubscribes from a specific channel.
   * @param chanel - The channel to unsubscribe from.
   */
  unsubscribe(chanel: string);
}

results matching ""

    No results matching ""