doriansmiley / lotusJS-MWV

MVW framework for applications based on lotusJS web components
2 stars 0 forks source link

Refactor injector to pass parameters to the constructor functions #8

Closed doriansmiley closed 6 years ago

doriansmiley commented 6 years ago

The new method signature would be:

public mapObject(key:any, constructor:Function, useSingleton:boolean=false, params:Array<any>):void{

We then could refactor inject pass the params in the call to the constructor function as follows:

return new (map.constructor as FunctionConstructor).apply(this, params);

I'm not sure if this will mess with scoping as this would refer to the context. I think a better approach would be something like

return new Function.prototype.bind.apply(map.constructor, params);
doriansmiley commented 6 years ago

done in 1.0.12