I have a class in CS:
class Model
constructor: (objectParams) ->
@object = ##object
###constructor
baseObject: => {}
validate: ko.computed =>
console.log ko.toJS @object
The problem is with 'validate' it is a prototype property where the binding context of the ko.computed function should be the constructor but instead gets compiled to this:
Model.prototype.validate = ko.computed(function() {
return console.log(ko.toJS(Model.object));
});
I want it to be binded to the constructor but the fat arrow => seems to be working only this way:
property: () =>
and this way it won't work
validate: =>
ko.computed => console.log ko.toJS @object
because ko.computed can't be defined inside a function
how can i solve?