Dependency Injection with Hilt: Fundamentals | raywenderlich.com

In this dependency injection course, learn how to apply an awesome new library called Hilt, to build dependency graphs, and inject dependencies into Android components in an automatic and lifecycle-aware way, without having to write a ton of boilerplate code, you had to write with Dagger.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/11277584-dependency-injection-with-hilt-fundamentals
1 Like

Hi, Thanks for the course! enjoyed it - right to the point.

I was wondering why did you design the login/register API calls to be non-suspending.
why did you prefer callbacks for these methods?

interface RemoteApiService {

  @POST("/api/register")
  fun registerUser(@Body request: UserDataRequest): Call<RegisterResponse>

  @GET("/api/note")
  suspend fun getNotes(): GetTasksResponse

  @POST("/api/login")
  fun loginUser(@Body request: UserDataRequest): Call<LoginResponse>

  @GET("/api/user/profile")
  suspend fun getMyProfile(): UserProfileResponse

  @POST("/api/note/complete")
  suspend fun completeTask(@Query("id") noteId: String): CompleteNoteResponse

  @POST("/api/note")
  suspend fun addTask(@Body request: AddTaskRequest): Task

  @DELETE("/api/note")
  suspend fun deleteNote(@Query("id") noteId: String): DeleteNoteResponse
}

Thanks!

1 Like

Hey @tomer !

I think that in the process of working on the project we updated most of the API calls for another course/project, but these two were left off as basic functions to showcase the difference between the two approaches!

In any way, doing it right would be having all of the functions as suspend for consistency. :]

1 Like

Learned a LOT. Thank you.