-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for easier debug of dependency graph #960
Comments
That sounds easiest to maintain, but it might be limited by or breaking encapsulation in places? Replacing the implementation of entire core files would be a potential alternative I've seen in other projects. Applying that here it would mean: Copy injector.ts: injector.debug.ts, sprinkle in many console.debug statements or save debug info into arrays to be inspected later ... e.g. especially where |
Another though would be to add the ability to pass a debug function to inject(). Inject(Service, { debug }) |
One debugging usecase, counting instances: // in some element:
static providers = [{ provide: EconomyService, use: EconomyService }]; // force a new instance for each element
// then I need to decorate my service like this to debug the amount of actual instances created (and alive?!):
@injectable
export class EconomyService {
static count = 0;
constructor() {
EconomyService.count++;
console.log('E', EconomyService.count);
}
} |
To help make it easier to debug injectors and their dependencies there should be an optional API that will describe how a particular series was resolved.
Initial thought it is export an additional injectDebug() function. (To make it tree shakeable)
This function would log the dependency tree for the injected service.
Cc @Phoscur
The text was updated successfully, but these errors were encountered: