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

Can't get ViewModel in standard Fragment #54

Closed
connorwyatt opened this issue Feb 16, 2018 · 3 comments
Closed

Can't get ViewModel in standard Fragment #54

connorwyatt opened this issue Feb 16, 2018 · 3 comments

Comments

@connorwyatt
Copy link

Hey, really enjoying the library, much prefer it to the other options available. I've found however that you can't inject a ViewModel from the Android Architecture Components library into a standard Android Fragment (i.e. not the v4 support Fragment).

I've seen that it's because the extension methods extend the v4 support Fragment (the getViewModel method and the viewModel delegated property), and was wondering if there is any reason that it does't support standard fragments?

If not I'm happy to create a PR to add the necessary extension methods to the standard fragment if that helps.

Thanks,

Connor

@connorwyatt
Copy link
Author

I've just been looking into a short term workaround, and have discovered that the Android Architecture Components library is only built to work with the support fragment, so I get why the extension methods aren't present. Closing the issue

@arnaudgiuliani
Copy link
Member

Hello,

also keep in mind that Google will provide only support for v4.Fragment. Don't know if you have seen the message from Jake Wharton:

image

@connorwyatt
Copy link
Author

Yeah thanks for the update, I found that shortly after doing a bit of a search, I'm not used to the Android ecosystem so thanks for posting :) It's quite odd that the blank fragment created by Android Studio is a standard framework fragment rather than a support one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants