1

I'm using Dagger Module to Inject MutableLiveData into my project

The problem is using different identifier for each MutableLiveData provider that returns the same object

  @Module
    public class LiveDataModule {

        @Provides
        public MutableLiveData<FirstModel> irstModel(){
            return  new MutableLiveData<>();
        }

        @Provides
        public MutableLiveData<SecondModel> secondModel(){
            return  new MutableLiveData<>();
        }

        @Provides
        public MutableLiveData<ThirdModel> thirdModel(){
            return  new MutableLiveData<>();
        }

        @Provides
        public MutableLiveData<FourthModel> fourthModel(){
            return  new MutableLiveData<>();
        }

        @Provides
        public MutableLiveData<FifthModel> fifthModel(){
            return  new MutableLiveData<>();
        }
    }

And so on for a long list

Is there a way to avoid this boilerplate?

shady
  • 11
  • 1

0 Answers0