Create a gist now

Instantly share code, notes, and snippets.

Aurelia messaging app - Bell
import {inject} from 'aurelia-framework';
import {EventAggregator} from 'aurelia-event-aggregator';
@inject(EventAggregator)
export class MessageBell {
constructor(eventAggregator){
this.eventAggregator = eventAggregator;
this.audio = new Audio('newMessage.m4a');
}
attached(){
this.newMessageSubscription = this.eventAggregator.subscribe('new-message', _ => {
this.audio.play();
});
}
detached() {
this.newMessageSubscription.dispose();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment