playmoweb / store2realm

Synchronize Realm with another Store. Realm Implementation for store2store library
MIT License
11 stars 6 forks source link

Use Generic an dagger_2 #13

Open amin3536 opened 6 years ago

amin3536 commented 6 years ago

hello how can i use Generic class like below? if use this cod can i call two different query same time? and how do i use injection for service ?

`
public class Service<T extends RealmObject & HasId> extends StoreService<T>{
    @Inject
    public Service(Class<T> clazz, ApiInterface apiInterface) {
       super(clazz, new Dao<T>(apiInterface));
        this.syncWith(new BaseRealmService<>(clazz));
   }

public static class Dao<T> extends StoreDao<T>{
    private final ApiInterface apiInterface;

    public Dao(ApiInterface apiInterface) {
        this.apiInterface = apiInterface;
    }

    @Override
    public Flowable<Optional<List<T>>> getAll(Filter filter, SortingMode sortingMode) {
        return super.getAll(filter, sortingMode);
    }
 }
 `

how can use dagger module for injection service?

           `@Module(includes = ApiModule.class)
            public class RepositoryModule<T> {

                @Provides
                 public Service serviceProvide(Class<T> tClass,ApiInterface apiInterface){
                     return new Service(tClass,apiInterface);
                 }

             }`