Created
October 23, 2016 19:26
-
-
Save freshcutdevelopment/e930a0b358b32decf7020a2addcaf656 to your computer and use it in GitHub Desktop.
Aurelia messaging app - Bell
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'; | |
@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