-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: use singleton model insteadof context #89
Conversation
Codecov ReportBase: 92.75% // Head: 92.75% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## master #89 +/- ##
=======================================
Coverage 92.75% 92.75%
=======================================
Files 214 214
Lines 4512 4512
Branches 460 458 -2
=======================================
Hits 4185 4185
Misses 327 327
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
加个 tracer 的单测,保证下 ctx 正常工作吧。 |
Singleton 里可以获取到当前上下文的。 |
就看 leoric emit 出来的事件,ctx 是否正常。 |
aa2c232
to
6890d46
Compare
👌🏻 之前理解错了 我以为要同时支持 context 和 singleton 注入 |
import { EGG_CONTEXT } from '@eggjs/egg-module-common'; | ||
|
||
export class ContextModeObject implements EggObject { | ||
export class SingletonModelObject implements EggObject { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
命名改为 Model 之前似乎是 typo
@@ -36,13 +40,13 @@ export class ContextModeObject implements EggObject { | |||
} | |||
|
|||
static get ctx() { | |||
return ctx?.get(EGG_CONTEXT); | |||
return self.getContext(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要改为实时获取,防止 Model 在不同 Service 中通过不同 ContextProto 或 SingletonProto 引入
2a7dcae
to
f674b2e
Compare
f674b2e
to
dff0a1f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Checklist
npm test
passesAffected core subsystem(s)
Description of change
Adherence to the principles of tegg@3.
Use Singleton instead of Context for @model.