Tuesday 30 May 2017

Access class inside dunction

I have a ready() function which contain an es6 class. I would like to instantiate this class outside the function, however I didn't succeed in making this working.

I don't want to use return function because the function can have more than one class.

Here is an example of what i want to do :

function ready(api) {
    class A extends api.C {
        contructor() {
            this.foo = "bar";
        }
    }

    class B extends A {
        contructor() {
            this.bar = "foo";
        }
    }
}

let classA = ready.A; // Here is the problem : I would like to access to the class prototype

The reason is my application have some plugins using remi npm package, and I want to export classes shared between all plugins. I don't know if it's possible, anybody have an idea ?



via SlumTheSlug

No comments:

Post a Comment