CoastalCommitsPastes/server/node_modules/cldrjs/doc/api/event/global_on.md
2022-03-06 16:46:59 -08:00

539 B

Cldr.on( event, listener )

Add a listener function to the specified event globally (for all instances).

Parameter Type Example
event String "get"
listener Function
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 );