knockout.js subscribe is not getting called on the first set

Viewed 4867

I have a simple model class with observables. I simply want to subscribe to its sets. Here is the code that I have:

var dto = function (data) {
    var self = this;
    self.Value1 = ko.observable(data.Value1);
    self.Value1.subscribe(function(){
         console.log('here');
    });   
};

the console.log doesn't get called when the Value1 is first set (i.e. ko.observable(data.Value1)

How do I set it up that subsribe function happens on both initial and when it changes.

4 Answers
Related