stomp-js / rx-stomp

STOMP adaptor for RxJS
Apache License 2.0
111 stars 21 forks source link

Call API, in rxStompServiceFactory , in beforeConnect #466

Closed shipra0278 closed 1 year ago

shipra0278 commented 1 year ago

Hi,

 myRxStompConfig.beforeConnect = () => {
    currentTry++;

    if(currentTry> 1)
    {
      console.log(`Connection Time:  (${new Date().getMilliseconds().toString()})
                  ReconnectDelay:   (${myRxStompConfig.reconnectDelay}) `)

        rxStomp.configure({reconnectDelay: 500 * Math.pow(2, currentTry)});
    }
    if (currentTry > maxConnectionAttempts) {
      console.log(`Exceeds max attempts (${maxConnectionAttempts}), will not try to connect now`);
      // It is valid to call deactivate from beforeConnect
      rxStomp.deactivate();

**Can i call API service to something?**
}

  rxStomp.configure(myRxStompConfig);

  if(currentTry !== maxConnectionAttempts)
     rxStomp.activate();

  return rxStomp;
}
kum-deepak commented 1 year ago

I am unable to understand your question.

In general, you can make external API calls from this callback. Depending on what you want to achieve, you may have to use async/await or Promise appropriately.