I have three observable objects as stated below:
self.firstName = ko.observable();
self.lastName = ko.observable();
self.middleName = ko.observable();
And than I have computed observable
as shown below:
ko.computed(function() {
var myMiddleName = self.middleName();
var Id = self.generateId(self.firstName.peek(), self.lastName.peek());
/* Other Operation */
});
As you see in above code, I am invoking computed function when value of the middleName
changes. So I have assigned it to temporary variable called myMiddleName
which is actually not used anywhere. Only just to invoke.
So far everything works fine. But when I run grunt lint
command it gives me an error
'myMiddleName' is assigned a value but never used. (no-unused-vars)
So how can I get rid of this error ?
Update - 1
after removing variable myMiddleName
as shown, warning doesn't appear. Is this correct way ?
ko.computed(function() {
self.middleName();
var Id = self.generateId(self.firstName.peek(), self.lastName.peek());
/* Other Operation */
});