# Ionic event fires too many times. Incremented by one each time it's triggered?

**URL:** <https://forum.ionicframework.com/t/ionic-event-fires-too-many-times-incremented-by-one-each-time-its-triggered/123077>\
**Category:** ionic-v3\
**Created:** [March 1, 2018, 10:07am UTC](https://forum.ionicframework.com/t/ionic-event-fires-too-many-times-incremented-by-one-each-time-its-triggered/123077 "2018-03-01T10:07:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hesters](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/hesters/32/118759_2.png) [@Hesters](https://forum.ionicframework.com/u/Hesters)\
**Post date:** [March 1, 2018, 10:07am UTC](https://forum.ionicframework.com/t/ionic-event-fires-too-many-times-incremented-by-one-each-time-its-triggered/123077/1 "2018-03-01T10:07:56Z")

</div>

Hi everyone 🙂

_TLDR: Subscription event fires too many times._

I have a event set up, that gets fired, when real time data comes in through a socket.

Through console logs I figured out, that the real time data correctly only comes in once.  
The event that gets fired, when the real time data comes in, also only gets fired once:

```auto
console.log("Event publish got fired!");
this.events.publish(EVENTSLUG_STAMP_UPDATE);

```

I only see this console log once each time the data comes in.

_Here comes the weird part!_  
The subscriptoin evets triggers multiple times! For each time real time data comes in, it triggers once more.

```auto
this.events.subscribe(EVENTSLUG_STAMP_UPDATE, () => {
  console.log("Event gets gets handled!");
  // Do some code here. This code gets done to many times.
});

```

So first time real time data comes in I see:

```auto
Event publish got fired!
Event gets gets handled!

```

in the console. Second time, I see

```auto
Event publish got fired!
Event gets gets handled!
Event gets gets handled!

```

Third time I see:

```auto
Event publish got fired!
Event gets gets handled!
Event gets gets handled!
Event gets gets handled!

```

And so on.  
I’m using [socket.io](http://socket.io) for the real time data. But as I said, filling my code with console logs I came to the conclusion, that only the subscribe event triggers multiple times. Incremented by one each time the event gets published again.

Any help would be appreciated!

---

<div class="post-metadata">

**Author:** ![sZerner](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@sZerner](https://forum.ionicframework.com/u/sZerner)\
**Post date:** [March 2, 2018, 11:18am UTC](https://forum.ionicframework.com/t/ionic-event-fires-too-many-times-incremented-by-one-each-time-its-triggered/123077/2 "2018-03-02T11:18:00Z")

</div>

Looks like you’re subscribing multiple times to the events. Where exactly do you subscribe?

---

<div class="post-metadata">

**Author:** ![Hesters](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/hesters/32/118759_2.png) [@Hesters](https://forum.ionicframework.com/u/Hesters)\
**Post date:** [March 3, 2018, 12:01pm UTC](https://forum.ionicframework.com/t/ionic-event-fires-too-many-times-incremented-by-one-each-time-its-triggered/123077/3 "2018-03-03T12:01:49Z")

</div>

That was it! I just call unsubscribe after the event’s subscription has fired!

---

<div class="post-metadata">

**Author:** ![vasanthb](https://avatars.discourse-cdn.com/v4/letter/v/4da419/32.png) [@vasanthb](https://forum.ionicframework.com/u/vasanthb)\
**Post date:** [March 26, 2020, 7:59am UTC](https://forum.ionicframework.com/t/ionic-event-fires-too-many-times-incremented-by-one-each-time-its-triggered/123077/4 "2020-03-26T07:59:50Z")

</div>

If events are used to communicate between 2 components, Ex Component B is triggering event and A is subscribing it. If you unsubscribe it from A then event will not work at all. Can you elaborate how you fixed it ?

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:01pm UTC](https://forum.ionicframework.com/t/ionic-event-fires-too-many-times-incremented-by-one-each-time-its-triggered/123077/5 "2021-07-19T21:01:22Z")

</div>


