I got two different view models and I need to call a function in one view model from other. To acheive this i try to use ko.subscribable()
var postbox=new ko.subscribable();// global variable
EmployeeViewModel
postbox.subscribe(function (showAlert) {
return that.ValidateEmployees(showAlert);
}, that, 'ValidateEmps');
that.ValidateEmployees=function(){
//validation logic
return true/false;
}
TaxCalculatorViewModel
var isEmpValid = postbox.notifySubscribers(true, "ValidateEmps");
if (!isEmpValid ) {
return false;
}
The prioblem is I am always getting isEmpValid=undefined
instead of getting the return value of ValidateEmployees
How to get the return value of a function when we pass using notifySubscribers?