I'm working on some existing code that exports a collection of key/value pairs by using a spread operation in the default export of a service like this:
keyValuePairs
{
key1: func1,
key2: func2
}
service.js
const myConst = {
//stuff here
};
export default {
myConst,
...keyValuePairs,
};
consumer.js
import myConst from 'service.js';
// invoke delegate function by referencing its key in collection
myConst.key1
How am I able to reference key1
in the consumer as myConst.key1
, when myConst
is the name of a constant that's included in the export?