TypeScript and Knockout: Define Computed Observables

ko.computed() in TypeScript On my second day of figuring out how to use knockout.js and TypeScript, I came upon computed observables and ran into trouble. As a point of reference, this is a simplified version of how I declared my ViewModel in pure JavaScript: var SampleViewModel = function () { var self = this; self.propertyOne = ko.observable(); self.propertyTwo = ko.observable(); self.propertyThree = ko.computed(function () { return self.propertyOne() + self.propertyTwo(); }); }; This simple ViewModel has three properties.…

TIL: Knockout View Models with jQuery Deferreds

I’m a knockout.js beginner and I’m no JavaScript Ninja. I’ve got a lot of habits that are carryovers from my years of C# and I sometimes find myself trying too hard to make those habits work in JavaScript when there are better ways. I learned how to use jQuery deferred objects and promises inside of a knockout view model. I was working on a project that relies heavily on knockout.js for data-binding and its MVVM awesomeness.…