Confusion with Sync gateway Pull Replication on Android

Viewed 240

I am trying to setup Channel based Pull replication on a Android device. I am using the Grocery-Sync Android client to push some data and retrieving the same through my Android client(push and Pull replication).

Here's my database configuration from the sync gateway file:

"cb":{
  "server":"http://172.17.0.5:8091",
  "users": { "GUEST": { "disabled": false, "admin_channels": ["*"] } },
   "allow_empty_password": true,
 "sync":``function(doc){
        if(doc.type == "LatestUpdate"){
                console.log("Inside LatestUpdate");
            channel(doc.kidId);
        }
        else{
            channel(doc.channels);
        }
    }

I have set custom property called kidId(hardcoded for the time being) while pushing the data from the Grocery-sync app. The Push replication works alright. Even it pushes to the correct channel as is evident from the logs:

Doc "afd8c40b-4431-49ab-be08-c87e409ee912" in channels "{2bea2709e58a49329de59c47d98535b}" Now, when I pull the data from my app, even though I have explicitly set a different channel, the logs suggest that it has still pulled the data.

Here's my Pull Replication code:

Replication pull = myApp.getDatabase().createPullReplication(url);
List<String> channels = new ArrayList<>();
channels.add("xyz");
pull.setContinuous(true);
pull.start();
pull.addChangeListener(this);
pull.setChannels(channels);

Is this correct behaviour or is something incorrect at my end? My assumption is that the Pull replication code shouldn't even have been looking at the data coming in from a different channel. Is that assumption correct?

0 Answers
Related