ES6 brings a nice module system into Javascript. Modules defined like this:
export default {
....
};
Can be easily imported into the source using import myLib from "myModule"
.
But what if module exports a "constructor" function like this:
export default ( actions ) => Reflux.createStore ( {
state: {
.....
},
config: {
.....
},
init: function() {
this.listenToMany ( actions );
},
}
You can import constructor function and then execute it by using
import MyStoreConstructor from "./datastore";
var store = MyStoreConstructor(actions);
Is there any more elegant way to do that?