Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Calling Subscription more than one time  #17

@Dhar3esh

Description

@Dhar3esh

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"}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions