create monitor.js page for Monitor.cshtml page

This commit is contained in:
chris.watts90@outlook.com 2017-06-18 19:38:29 +01:00
parent 3d3a552664
commit c985b35bb5

View File

@ -0,0 +1,28 @@
function ViewModel() {
"use strict";
var self = this;
self.raceSessions = ko.observable();
$.get("/api/monitor", {}, self.raceSessions);
self.tmrHandle = setTimeout(function () {
self.getData();
}, 2000);
self.getData = function () {
$.get("/api/monitor", {}, self.raceSessions)
.done(function() {
console.log("done");
})
.always(function() {
self.tmrHandle = setTimeout(self.getData, 2000);
});
};
};
ViewModel.prototype.dispose = function () {
"use strict";
window.clearInterval(self.tmrHandle);
console.log("disposed of timer");
};
ko.applyBindings(new ViewModel());