Question: I have an `ExampleView` class which should be singleton. Inside this class I have method `render` which I would like to call from another js file via object name 'ExampleView'.
Here is the code:

```
import View from './view';

class ExampleView extends View {
    render() {
        return `<span>Test</span>`;
    }
}
export default new ExampleView(); //<- exporting as singleton and this object I try to get via it's name

```

First I should do is retrieve somehow exported singleton object `ExampleView` from name 'ExampleView' and then call method `render`.

```
class Test {
    getInstanceOfModuleByName(name) {
        //window[name].render();
    }
}

```

The problem is that I cannot find any way to get `ExampleView` instance from name, but my `ExampleView` class needs to be a singleton. 

I know I can do this in following way and then call it by `window['ExampleView'].render()`:

```
ExampleView = {
    render: function() {
        return `<span>Test</span>`;
    }
}

```

But I really need to implement it with modulable ES6.

Can you explain me what I should do?

Answer: 
Populating global scope is not the ES6 way. I think you can do it like this to your `export`

```
//
// Class definition
//
window.ExampleView = new ExampleView();

export default window.ExampleView;

```
You just import the instance

```
import whateverYouWantToCallYourViewInstance from './ExampleView'

// snip

return whateverYouWantToCallYourViewInstance.render();

```

It will be the same object.

---

Worth noting: Singletons are evil. Using the ES module system to pass instances around is a bit of abuse.