Giter Club home page Giter Club logo

mvvmposts's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mvvmposts's Issues

How to make this code better to support many different view models?

Hi,

I copied the code you wrote hoping that it would be a good start for me to write good Android applications applying the Android Architecture Components and two of the most used libraries, Dagger and Retrofit, and I am confident your way is a good way because by what I could see from Google's sample codes, they're similar but simpler. I know there isn't a correct way but more efficient ways, and that is why I write this issue hoping you or someone else can help me, and probably other people, with this problem.

While inspecting what I have copied, it came into my mind about a way to refactor certain parts of the code to adapt it to several different view models. Let's start with the ViewModelInjector.kt class. The inject method expects a PostListViewModel as an argument, and then, this same method is initiated in BaseViewModel.kt, a class that will probably be extended by many other view model classes.

I wanted to try to refactor it and make it more generic and accept a T type as a parameter, but none of what I did help. I no longer have my attempts either. Because the way it is now, the way to support many different view model classes is if I write something like this in ViewModelInjector.kt:

fun injectFoo(fooViewModel: FooViewModel)
fun injectBar(barViewModel: BarViewModel)
...

and then, in the BaseViewModel.kt, do it like this:

init {
    injectFoo()
    injectBar()
}

private fun inject() {
    when (this) {
        is FooViewModel -> injector.injectFoo(this)
        is BarViewModel -> injector.injectBar(this)
    }
}

I'm sure there is a way to fix this and write it in a way that is better, is there not?

I hope someone can help me with this! Thank you.

Missing class

I don't find DaggerViewModelInjector class from injection/component package.

Replace RxAndroid by Coroutine ?

I saw some tutorial/example where Coroutine is used instead of RxJava and/or RxAndroid.
Do you think it could improve the code and make it easier to read and/or implement ?

Unresolved reference DaggerViewModelInjector

Hi!
I'm studying your architecture with your tutorial and code. But I get this error
captura de pantalla 2018-08-10 a las 3 40 52
I don't know what is DaggerViewModelInjector.
Thanks so much by your tutorial and code.

Regards!

Class or Interface Missing: DaggerViewModelInjector

Reporting one issue while following and implementing your code.
Under package net.gahfy.mvvmposts.base
Class BaseViewModel
Unresolved Item DaggerViewModelInjector
In the code mentioned as net.gahfy.mvvmposts.injection.component.DaggerViewModelInjector
So please let us know if its class or interface.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.