ParseLiveQuery icon indicating copy to clipboard operation
ParseLiveQuery copied to clipboard

Calling Subscription more than one time

Open Dhar3esh opened this issue 9 years ago • 2 comments

Works fine

When I subscribe first time its work fine

Not working

when i move back from current screen after unsubscribing and come back to same screen it invoking more than one time

  isSubscribed = false;
   if(!isSubscribed) {
                isSubscribed = true;
                sub = new BaseQuery.Builder("Message")
                        .addField("message")
                        .addField(MSG_RECEIVER_USER_ID)
                        .addField(MSG_SENDER_USER_ID)
                        .build()
                        .subscribe();

                sub.on(LiveQueryEvent.CREATE, new OnListener() {
                    @Override
                    public void on(JSONObject object) {
                        Log.e(TAG, "on: " + object);
                           
                        // Action to be executed here when an object that matches
                        // The filter you set up
                    }
                });
            }else{
                if(sub != null){
                    if(sub.isSubscribed()){
                        sub.unsubscribe();
                        isSubscribed = false;
                    }
                }
            }
     }


output (invoking more than one times)

on: {"op":"create","clientId":22,"requestId":2,"object":{"className":"Message",
"objectId":"MoItqxnFGC","updatedAt":"2017-02-27T10:37:08.679Z","createdAt":"2017-02-27T10:37:08.679Z","message":"dhjjf",
"receiver_user_id":"Rb4bg9Nv5z","sender_user_id":"ewaCQ6Y2I4"}}


on: {"op":"create","clientId":22,"requestId":2,"object":{"className":"Message",
"objectId":"MoItqxnFGC","updatedAt":"2017-02-27T10:37:08.679Z","createdAt":"2017-02-27T10:37:08.679Z","message":"dhjjf",
"receiver_user_id":"Rb4bg9Nv5z","sender_user_id":"ewaCQ6Y2I4"}}

Dhar3esh avatar Feb 27 '17 10:02 Dhar3esh

hi facing same issue here @TGIO would appreciate some information and how to solve

madibalive avatar Mar 19 '17 15:03 madibalive

for anyone facing this issue, add the actual project as library module , instead of compile "xxxxxx" that solve my problem

madibalive avatar Apr 03 '17 17:04 madibalive