Skip to content

Instantly share code, notes, and snippets.

@freshcutdevelopment
Created September 16, 2017 10:17
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save freshcutdevelopment/97f595e12976e8a6b21016ca0f29148a to your computer and use it in GitHub Desktop.
Aurelia code quality - part 6
import {EventAggregator} from 'aurelia-event-aggregator';
import {inject} from 'aurelia-framework';
@inject(EventAggregator)
export class App{
constructor(eventAggregator){
this.eventAggregator = eventAggregator;
}
attached(){
this.greetingAddedSubscription =
this.eventAggregator.subscribe(`greeting-added`, greeting => {
alert(greeting);
});
}
detached(){
//clean up the subscription when app component is removed from the DOM
this.greetingAddedSubscription.dispose();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment