Thursday, 4 May 2017

How exactly to inject a dependency.

I'd really like some help on how to inject a dependency. I've been assuming all this time it's essentially writing functions that return other functions (which contain the actual operation), but are passed dependencies as parameters. That dependency can be used for construction or operation inside the returned function, but the actual dependency own't be returned. Is this how it works? function Hello (jQuery, Handlebars) { return new function (parameter1, parameter2) { return $(Handlebars.compile(parameter1, paramter2)); } } var actualHelloFunction = Hello(require('jquery'), require('handlebars')); actualHelloFunction("paramter1", "parameter2");

Submitted May 04, 2017 at 11:17PM by Crowesco

No comments:

Post a Comment