Created
September 16, 2017 10:17
-
-
Save freshcutdevelopment/97f595e12976e8a6b21016ca0f29148a to your computer and use it in GitHub Desktop.
Aurelia code quality - part 6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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