mirror of
https://github.com/fergalmoran/dss.web.git
synced 2026-02-15 20:44:34 +00:00
26 lines
747 B
JavaScript
26 lines
747 B
JavaScript
'use strict';
|
|
|
|
angular.module('dssWebApp')
|
|
.factory('TimedNotificationService', function ($rootScope) {
|
|
// events:
|
|
var TIME_AGO_TICK = "e:timeAgo";
|
|
var timeAgoTick = function () {
|
|
$rootScope.$broadcast(TIME_AGO_TICK);
|
|
};
|
|
// every minute, publish/$broadcast a TIME_AGO_TICK event
|
|
setInterval(function () {
|
|
timeAgoTick();
|
|
$rootScope.$apply();
|
|
}, 1000 * 60);
|
|
return {
|
|
// publish
|
|
timeAgoTick: timeAgoTick,
|
|
// subscribe
|
|
onTimeAgo: function ($scope, handler) {
|
|
$scope.$on(TIME_AGO_TICK, function () {
|
|
handler();
|
|
});
|
|
}
|
|
};
|
|
});
|