Code Monkey home page Code Monkey logo

hilt-mvvm-retrofit-architecture's Introduction

Hilt-MVVM-Retrofit-Architecture

The "Hilt-MVVM-Retrofit-Architecture" repository is an Android project that demonstrates the integration of MVVM, Hilt for dependency injection, and Retrofit for network requests, providing a modular and testable codebase for Android applications. Hilt-MVVM-Retrofit-Architecture

This is a sample app which uses HILT as dependency Injection in MVVM pattern. It also uses Retrofit for network communication and Parcelize the Model Class.

Understanding Hilt (Dagger)

To understand Dagger we have to understand the 4 major annotations,

Module

Component

Provides

Inject

To understand it better in a basic way, think module as a provider of dependency and consider an activity or any other class as a consumer. Now to provide dependency from provider to consumer we have a bridge between them, in Dagger, Component work as that specific bridge. A module is a class and we annotate it with @Module for Dagger to understand it as Module.

A component is an interface, which is annotated with @Component and takes modules in it. (But now, this annotation is not required in Dagger-Hilt)

Provides are annotation which is used in Module class to provide dependency and,

Inject is an annotation that is used to define a dependency inside the consumer. inject

Add dependency in project

Hilt implementation 'com.google.dagger:hilt-android:2.28-alpha' kapt 'com.google.dagger:hilt-android-compiler:2.28-alpha' implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha01' kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha01' Network

implementation "com.squareup.retrofit2:converter-gson:2.6.2"
implementation "com.squareup.retrofit2:retrofit:2.8.1"
implementation "com.squareup.okhttp3:okhttp:4.7.2"
implementation "com.squareup.okhttp3:logging-interceptor:4.7.2"

Coroutine

implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.6"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.6"

The app has following packages:

model: It contains all the data accessing and manipulating components. module: It contains the files required by Dagger ui: View classes along with their corresponding ViewModel. network: It contains all helper classes for network call. utils: Utility classes.

hilt-mvvm-retrofit-architecture's People

Contributors

bishal559 avatar

Stargazers

 avatar

Watchers

 avatar

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.