loopbackio / loopback-next

LoopBack makes it easy to build modern API applications that require complex integrations.
https://loopback.io
Other
4.95k stars 1.07k forks source link

Support for dep injection inside of lifecycle #6643

Closed mdbetancourt closed 3 years ago

mdbetancourt commented 3 years ago

Suggestion

Allow dependency injection in start|init lifecycles

Use Cases

when dependencies is only used in the lifecycle method could be useful to avoid pollute the object with unnecessaries deps also we can inject dependencies everywhere (constructor, properties, methods) but not in lifecycle is some counter intuitive

Examples

class UserRepository extends DefaultCrudRepository implements LifeCycleObserver {
  ...
  start(@inject('xxx') dep: Dep) {}
}

Acceptance criteria

TBD - will be filled by the team.

mdbetancourt commented 3 years ago

closed with https://github.com/strongloop/loopback-next/pull/6740