CoastalCommitsPastes/server/node_modules/cldrjs/doc/api/event/global_on.md

33 lines
539 B
Markdown
Raw Normal View History

2022-03-06 19:46:59 -05:00
## Cldr.on( event, listener )
Add a listener function to the specified event globally (for all instances).
| Parameter | Type | Example |
| --- | --- | --- |
| *event* | String | `"get"` |
| *listener* | Function | |
```javascript
Cldr.load({
foo: "bar"
});
function log( path, value ) {
console.log( "Got", path, value );
}
Cldr.on( "get", log );
en = new Cldr( "en" );
en.get( "foo" );
// Got foo bar (logged)
// ➡ bar
zh = new Cldr( "zh" );
zh.get( "foo" );
// Got foo bar (logged)
// ➡ bar
Cldr.off( "get", log );
```