Get return value of a function using notifySubscribers

自闭症网瘾萝莉.ら 提交于 2019-12-25 07:59:01

问题


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?

来源:https://stackoverflow.com/questions/28828242/get-return-value-of-a-function-using-notifysubscribers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!