1.0.0 • Published 1 year ago

newskit-ioc v1.0.0

Weekly downloads
2
License
ISC
Repository
github
Last release
1 year ago

NewsUK Dependency Injection Container

Introduction

This container use the same approach as the DI container from Angular 1 (it uses parameter names). This means it doesn't need type references to exist at runtime, it simply goes off dependency parameter names. This is the easiest and least intrusive way we can get proper DI into our code base. It's also extremely well documented in the community and there's a whole chapter dedicated to it (called "Wiring Modules") in this well known Node JS text book: Node.js Design Patterns. Basically this is the traditional way of doing DI in JavaScript.

Features of the container

  • Dependency resolution via parameter names (it means minification of these should be disabled)
  • Supports transient (instance per resolution) and singleton (instance per container) bindings
  • Does not support circular dependencies
  • Supports injecting anything (including functions, strings, objects, etc.)
  • Always resolves asynchronously - this is so that it can have asynchronously resolved dependencies (i.e. SSM config, database connections, etc.)
  • Supports resolution of existing registered dependencies by name (useful for getting existing singleton instances or when you don't know which implementation is registered)