Created
September 16, 2017 10:16
-
-
Save freshcutdevelopment/2476acf6b0773d97c7d440fd0f23d8c8 to your computer and use it in GitHub Desktop.
Aurelia code quality - part 5
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 {inject} from 'aurelia-framework'; | |
import {EventAggregator} from 'aurelia-event-aggregator'; //import the EventAggregator class | |
import {GreeterService} from './services/greeter-service.js'; | |
@inject(GreeterService, EventAggregator) | |
export class Greeter{ | |
constructor(greeterService, eventAggregator){ | |
this.greeterService = greeterService; | |
this.eventAggregator = eventAggregator; | |
} | |
attached(){ //called when the greeter component is attached to the DOM | |
this.greetings = this.greeterService.loadGreetings(); | |
} | |
addGreeting(){ | |
this.greetings.add(this.greeting); //add a new greeting to the list | |
this.eventAggregator.publish(`greeting-added`, this.greeting); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment