Refactor code based on review #3
I was reading your blog post and I wanted to place a question. Since there's no way to comment (I don't use Twitter), and no "issues" tab is available in this repo, I'm going to comment on this pull request. Hope you don't mind ^^.
Couldn't we just (I use Dagger and Data Binding):
What do you think of this?
First of all, I've now added an Issues tab over there for discussions, didn't realize that GitHub doesn't have one for forks by default (which I believe is what happened?).
And yes, sure, lazy initialization of a ViewModel makes sense, and should work perfectly fine! If that's how you use it, and it works for you, there's not much of a reason to change it.
However, since I know that I'll be using it at some point anyway (thus never actually avoiding its creation), I would probably just initialize it at one known point in the code, which makes it easier to reason about. Plus
(And then in my actual applications, I have ViewModel creation abstracted away by some base classes. so I never actually write code like this myself.)