Skip to content
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

Dependency Injection #9085

Merged
merged 185 commits into from
Sep 16, 2022
Merged

Dependency Injection #9085

merged 185 commits into from
Sep 16, 2022

Conversation

syuilo
Copy link
Member

@syuilo syuilo commented Sep 6, 2022

What

Resolve #8458

イメージ
image

TODO

  • configをservice化

Why

Additional info (optional)

@github-actions github-actions bot added the packages/backend Server side specific issue/PR label Sep 6, 2022
@syuilo syuilo changed the base branch from develop to jest September 6, 2022 15:12
@github-actions github-actions bot added the packages/frontend Client side specific issue/PR label Sep 8, 2022
@github-actions github-actions bot removed the packages/frontend Client side specific issue/PR label Sep 8, 2022
@syuilo
Copy link
Member Author

syuilo commented Sep 10, 2022

なんもわからんくなってきた

@syuilo
Copy link
Member Author

syuilo commented Sep 10, 2022

わかってきた

@syuilo
Copy link
Member Author

syuilo commented Sep 11, 2022

あるサービスのメソッド内で別のサービスのクラスのインスタンスを動的に作成して使うことってできないのかな
作ることになるインスタンスの数やコンストラクタ引数もメソッドが実行されるまでは分からないから予め依存関係として定義しておくことはできない

@syuilo
Copy link
Member Author

syuilo commented Sep 11, 2022

@syuilo
Copy link
Member Author

syuilo commented Sep 11, 2022

@syuilo
Copy link
Member Author

syuilo commented Sep 16, 2022

95%くらい終わった

@syuilo
Copy link
Member Author

syuilo commented Sep 16, 2022

Dependency以外全部Injection

@syuilo
Copy link
Member Author

syuilo commented Sep 16, 2022

起動の時が近い

@syuilo
Copy link
Member Author

syuilo commented Sep 16, 2022

サービス内でthisが空オブジェクトになるときがあり謎

@syuilo
Copy link
Member Author

syuilo commented Sep 16, 2022

moduleRef.get で取得したサービスだとそうなるっぽい
とはいえmoduleRef使わないと #9085 (comment) になるし

@syuilo
Copy link
Member Author

syuilo commented Sep 16, 2022

お、onModuleInitライフサイクルフック内でgetすれば大丈夫そう

@syuilo
Copy link
Member Author

syuilo commented Sep 16, 2022

動いた

@syuilo syuilo marked this pull request as ready for review September 16, 2022 17:26
@github-actions github-actions bot added the packages/frontend Client side specific issue/PR label Sep 16, 2022
@syuilo syuilo merged commit d4df71e into jest Sep 16, 2022
@syuilo syuilo deleted the di branch September 16, 2022 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages/backend Server side specific issue/PR packages/frontend Client side specific issue/PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dependency injection
1 participant