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