TGIO / ParseLiveQuery

Very simple and modern implementation, it lacks tests and extra functionality at this moment but i'm working on it.
Apache License 2.0
48 stars 10 forks source link

Executing multiple times #8

Closed zouzoux closed 8 years ago

zouzoux commented 8 years ago

I am using a recyclerView and I have two classes one which contains the recyclerView and were I set the adapter and one class for the adapter.

In the first class if I set this :

 final Subscription subscription = new BaseQuery.Builder("Posts")
                    .where("objectId", ratingSimplePost.getPostId())
                    .build()
                    .subscribe();

            //  Listen
            subscription.on(Subscription.UPDATE, new OnListener() {
                @Override
                public void on(final JSONObject object) {
                    Log.d(MainActivity.class.getSimpleName(),"Updated");
}
});

What's inside the on method gets executed one time but if I put it inside the adapter class in the onBindViewHolder method the on method gets executed multiple times? Any idea why this is happening and is there a way to fix it ?

TGIO commented 8 years ago

u should not subscribe inside onBindViewHolder