mirror of
https://github.com/danbee/mpd-client
synced 2025-03-04 08:39:09 +00:00
12 lines
297 B
JavaScript
12 lines
297 B
JavaScript
mpdClient.factory('serverEvents', function ($rootScope) {
|
|
|
|
var events = new EventSource('/api/stream')
|
|
|
|
events.onmessage = function (e) {
|
|
response = JSON.parse(e.data);
|
|
$rootScope.$apply(function () {
|
|
$rootScope.$broadcast('update:' + response.type, response.data)
|
|
})
|
|
}
|
|
})
|