Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Generic an dagger_2 #13

Open
amin3536 opened this issue May 18, 2018 · 0 comments
Open

Use Generic an dagger_2 #13

amin3536 opened this issue May 18, 2018 · 0 comments

Comments

@amin3536
Copy link

amin3536 commented May 18, 2018

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);
                 }

             }`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant