Skip to content

Instantly share code, notes, and snippets.

@freshcutdevelopment
Created October 23, 2016 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freshcutdevelopment/e930a0b358b32decf7020a2addcaf656 to your computer and use it in GitHub Desktop.
Save freshcutdevelopment/e930a0b358b32decf7020a2addcaf656 to your computer and use it in GitHub Desktop.
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