Hey,
after struggling myself for quite a while I decided to ask here on the forums.
I can’t figure out what the dependency injection framework for JS, used by camunda, is exactly. It isn’t https://www.npmjs.com/package/inject-js this one here right?
In addition it seems like you use multiple DI frameworks throughout your different projects, is this correct? Sometimes I saw object.$inject = [ array of strings ]
but I also saw injector.invoke
and injector.get(stringName, boolean)
, but also quite amusingly object.$inject = [ 'injector' ]
It also surely can’t be the angular injection API since you don’t use annotated injections and your frontend is built with electron and react.
I would appreciate some hints as to where I can learn more about the DI framework (s) used in the modeler and how to tweak the app with my own dependencies. Also if the framework is documented in your github I’m sorry for asking but it wasn’t really clear to me.
EDIT: After some fiddling around I noticed that you call your injection framework from diagram js, and apparently the DI framework is called didi
but I never heard of that framework, and $inject
also isn’t mentioned there. GitHub - nikku/didi: Dependency Injection for JavaScript
EDIT 2: I think I found the actual part where injector is received from the method. But I’m still confused as to how to create my own dependencies
var fnDef = function fnDef(fn) {
var locals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (typeof fn !== 'function') {
if (isArray(fn)) {
fn = annotate(fn.slice());
} else {
throw new Error('Cannot invoke "' + fn + '". Expected a function!');
}
}
var inject = fn.$inject || parse(fn);
var dependencies = inject.map(function (dep) {
if (hasProp(locals, dep)) {
return locals[dep];
} else {
return get(dep);
}
});
return {
fn: fn,
dependencies: dependencies
};
};
Thanks