, -, , Knockout , , .
, , ,
ko.postbox.subscribe("foo", function(payload) { ... });
, , . , .
, , , , API, , -, , - , , , , .
, , , , , , . ( , )
, postbox.subscribe , , , "" , , , , .
, , , , ,
define(["require", "exports", "knockout", 'knockout.postbox', "text!application/components/pagecontrols/template.html"], function (require, exports, ko, postbox) {
var Template = require("text!application/components/pagecontrols/template.html");
var ViewModel = (function () {
function ViewModel(params) {
var _this = this;
this.someDataBoundVar = ko.observable("");
this.mySubscriptionHandler = ko.postbox.subscribe("foo", function(){
});
}
ViewModel.prototype.somePublicFunction = function () {
postbox.publish("SomeMessage", { data: "some data" });
};
return ViewModel;
ViewModel.prototype.dispose = function () {
this.mySubscriptionHandler.dispose();
};
return ViewModel;
})();
return { viewModel: ViewModel, template: Template, dispose: this.dispose };
});
, "dispose", , KnockoutJS , KO-, KO , , .
, Iv'e , , , , , , , dispose .
, , , . , Typescript, , , , , , .