How would one do dependency injection in scala?

前端 未结 9 1755
鱼传尺愫
鱼传尺愫 2021-01-30 12:25

I\'m still at the beginning in learning scala in addition to java and i didn\'t get it how is one supposed to do DI there? can or should i use an existing DI library, should it

9条回答
  •  耶瑟儿~
    2021-01-30 13:08

    A new dependency injection library specifically for Scala is Dick Wall's SubCut.

    Whereas the Jonas Bonér article referenced in Dan Story's answer emphasizes compile-time bound instances and static injection (via mix-ins), SubCut is based on runtime initialization of immutable modules, and dynamic injection by querying the bound modules by type, string names, or scala.Symbol names.

    You can read more about the comparison with the Cake pattern in the GettingStarted document.

提交回复
热议问题