# Aurelia Event Aggregator not working

**URL:** <https://discourse.aurelia.io/t/aurelia-event-aggregator-not-working/2005>\
**Category:** Help Requests\
**Created:** [December 10, 2018, 3:26pm UTC](https://discourse.aurelia.io/t/aurelia-event-aggregator-not-working/2005 "2018-12-10T15:26:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BorisDedejski](https://avatars.discourse-cdn.com/v4/letter/b/b77776/32.png) [@BorisDedejski](https://discourse.aurelia.io/u/BorisDedejski)\
**Post date:** [December 10, 2018, 3:26pm UTC](https://discourse.aurelia.io/t/aurelia-event-aggregator-not-working/2005/1 "2018-12-10T15:26:37Z")

</div>

Aurelia event aggregator is having big problems in my applicaton.  
import { ApiService } from ‘./…/…/shared/ApiService’;  
import { autoinject } from “aurelia-framework”;  
import { Router } from “aurelia-router”;  
import { EventAggregator } from “aurelia-event-aggregator”;  
import { TestEvent } from ‘shared/TestEvent’;

```
@autoinject
export class Class1{
  constructor(private router: Router, private eventAggregator: EventAggregator, private api: ApiService) {
    this.eventAggregator = eventAggregator;
  }
  attached() {
  }

  try() {
    console.log('asd')
    this.eventAggregator.publish("test");
  }
  navigateToStep2() {
    this.router.navigate('listyourcar-3')
  }
}

```

The .ts file i want to subscribe in is  
import { ApiService } from ‘./…/…/shared/ApiService’;  
import { autoinject } from “aurelia-framework”;  
import { Router } from “aurelia-router”;  
import { DialogService } from “aurelia-dialog”;  
import { EventAggregator } from ‘aurelia-event-aggregator’;  
import { TestEvent } from ‘shared/TestEvent’;

```
@autoinject
export class Class2{

  listOfImages: any;
  imageId: any;
  subs: any;
  constructor(private router: Router, private dialog: DialogService, private api: ApiService,
    private eventAggregator: EventAggregator) {

    this.eventAggregator = eventAggregator;

    this.listOfImages = [];
  }

  attached(){
    this.subs = this.eventAggregator.subscribe("test", () => {
      console.log('subscribed')
    })
  }
  detached(){
    this.subs.dispose();
  }

```

If i visit the class2 component than on the second time the method subscribes but when not added dispose. When i add dispose(); the method dont subscribes any time.  
Can you help

---

<div class="post-metadata">

**Author:** ![bigopon](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/bigopon/32/18_2.png) [@bigopon](https://discourse.aurelia.io/u/bigopon)\
**Post date:** [December 10, 2018, 7:26pm UTC](https://discourse.aurelia.io/t/aurelia-event-aggregator-not-working/2005/2 "2018-12-10T19:26:03Z")

</div>

Can you help describe the issue clearer? Based on what you described, I made this as a base for you to repro [https://codesandbox.io/s/v64x168yl0](https://codesandbox.io/s/v64x168yl0)
