Open
Conversation
added 2 commits
June 5, 2018 22:23
k-kohey
reviewed
Mar 17, 2019
|
|
||
| var window: UIWindow? | ||
| lazy var applicationCoordinator = ApplicationCoordinator(window: self.window!) | ||
| lazy var coordinator = DependencyManager.getResolver().resolve(ApplicationCoordinator.self)! |
There was a problem hiding this comment.
CoordinatorをDIするメリットがあまり思いつかなかったんだが,どういったメリットが有るんだろうか.
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
|
|
||
| print(viewModel) |
| private func setUpDataBinding() { | ||
| signInButton.rx.tap | ||
| .subscribe({ _ in self.viewModel?.onSignInClicked() }) | ||
| .subscribe({ _ in self.viewModel.onSignInClicked() }) |
There was a problem hiding this comment.
循環参照を起こします.
下記のように変更することを推奨します.
.subscribe({ [weak self] _ in self?.viewModel.onSignInClicked() })
| import SwinjectStoryboard | ||
|
|
||
| class DependencyManager { | ||
| static let assembler = Assembler([ |
There was a problem hiding this comment.
カプセル化を試みているなら,ここはprivateの方がいいかもしれないです.
また,この使用方法ならclassじゃなくてenumでも良いかも.
There was a problem hiding this comment.
また,この実装だとどこからでもDI出来てしまうが,それが実装意図に沿っているかも併せて気になりました.
|
|
||
| class WelcomeViewModel { | ||
| var coordinator: WelcomeCoordinator? | ||
| let coordinator: WelcomeCoordinator |
There was a problem hiding this comment.
CoordinatorがWelcomeViewControllerへの参照を持っていれば,循環参照が起きてそうだと思ったんだが,どうだろうか.
coordinatorはaqppDelegateに保持されているので,解放されることは無さそう.なので
private unowned let coordinator: WelcomeCoordinator
が良さそう.
一方で,ViewModelがCoordinatorを直接持つ必要も無さそうなので,外部から遷移ロジックを注入するのが一番安全かも.
| class ViewControllerAssembly: Assembly { | ||
| func assemble(container: Container) { | ||
| container.storyboardInitCompleted(WelcomeViewConstoller.self) { res, viewController in | ||
| viewController.viewModel = res.resolve(WelcomeViewModel.self)! |
There was a problem hiding this comment.
抽象に依存してないが,これは実装意図に沿っているだろうか.
また,ここでランタイムエラーが起きないかも併せて気になりました.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
close #130
なぜか動きません。