Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Aurelia messaging app - List
import {inject} from 'aurelia-framework';
import {EventAggregator} from 'aurelia-event-aggregator';
@inject(EventAggregator)
export class MessageList{
constructor(eventAggregator){
this.eventAggregator = eventAggregator;
this.messages = [];
}
attached(){
this.messageReceivedSubscription = this.eventAggregator.subscribe('new-message', message => {
this.messages.unshift({ message: message, date: new Date() });
});
}
detached() {
this.messageReceivedSubscription.dispose();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment