Skip to main content
6 of 12
edited body
Stephen Paul
  • 39.4k
  • 18
  • 99
  • 76

I also encountered this by injecting service A into service B and vice versa.

Personally, I'm glad that this fails fast as it should probably be avoided anyway. If you want your services to be more modular / re-usable, it's best to avoid circular references as much as possible. This post highlights the pitfalls surrounding that.

Therefore:

  • If you feel the classes do a lot of intercommunication, you might want to consider merging the 2 services into 1 class.
  • If the above doesn't work for you, consider using a 3rd service, (an EventService) which both services can inject in order to exchange messages.
Stephen Paul
  • 39.4k
  • 18
  • 99
  • 76