Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is purpose of exportProperty function in knockout.js library?

I am reading knockout.js library source codes and i saw such as function calls

ko.exportProperty(this, 'subscribe', this.subscribe);
ko.exportProperty(this, 'extend', this.extend);
ko.exportProperty(this, 'getSubscriptionsCount', this.getSubscriptionsCount);

You can check source code in here

and exportProperty definition is

ko.exportProperty = function(owner, publicName, object) {
  owner[publicName] = object;
};

Source code is here.

I am trying to understand what it does. But what i understand exportProperty usage does not change or break anything on object when i look at usages at upside.

Can you explain what for exportProperty function called ?

like image 843
Freshblood Avatar asked Nov 23 '25 14:11

Freshblood


1 Answers

The minified file is created via Google's Closure Compiler, which can do some pretty aggressive minification. The ko.exportProperty calls ensure that the property will be included in the minimized output with the its full name with the same name. The calls that are exported can be considered the "public API".

like image 74
RP Niemeyer Avatar answered Nov 25 '25 03:11

RP Niemeyer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!