TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Why and how to use service injection in Node.js

23 点作者 yasserf超过 3 年前

4 条评论

0xcoffee超过 3 年前
Nitpick, but isn't this service lookup disguised as injection? Also somewhat considered an anti-pattern by some. Although I'm not sure how 'real' DI would work in Node, since it's requires knowledge of types to inject.
评论 #29058290 未加载
评论 #29058895 未加载
评论 #29063482 未加载
yasserf超过 3 年前
Added a follow up blog entry here: <a href="https:&#x2F;&#x2F;vramework.io&#x2F;blog&#x2F;20211101-service-lookup-local-vs-cloud&#x2F;" rel="nofollow">https:&#x2F;&#x2F;vramework.io&#x2F;blog&#x2F;20211101-service-lookup-local-vs-c...</a>
ramesh31超过 3 年前
Can anyone explain how this is better than just importing a singleton instance where it&#x27;s needed? I&#x27;ve never really understood the point of dependency injection.
评论 #29058484 未加载
评论 #29059584 未加载
评论 #29058045 未加载
评论 #29058145 未加载
评论 #29057994 未加载
评论 #29058035 未加载
评论 #29058156 未加载
评论 #29058055 未加载
评论 #29058986 未加载
gkop超过 3 年前
Do you get “intellisense” on the injected services?
评论 #29063514 未加载
评论 #29058389 未加载