[IONIC-5]: Network on connect triggers multiples times. How to avoid it?

Network on connect triggers multiple times. when back to online in ionic 5. How to avoid it?
Here’s My code:

initializeApp() {
 this.platform.ready().then(() => {
this.network.onDisconnect().subscribe(() => {
  alert('Back to online');

This will trigger alert multiple times.
Expected one alert when on connect.
Please help me.

Is there a more complete example that you could provide? Like a repo on github?

How about distinctUntilChanged?