SaltechSystems / couchbase_lite

Flutter plugin for the Community edition of Couchbase Lite. Couchbase Lite is an embedded lightweight, document-oriented (NoSQL), syncable database engine.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ReplicatorType.pushAndPull data push performs but pull not performing

Kazi-Wahed opened this issue · comments

ReplicatorType.pushAndPull using to pull and push data from couchbase sync server, document uploaded to server but pull not performing.

Project Configuration

flutter sdk version: sdk: ">=2.17.0 <3.0.0"

couchbase_lite: ^3.0.0-nullsafety.2

code

 final config = ReplicatorConfiguration(_database, _couchbaseConfig.url)
                    ..replicatorType = ReplicatorType.pushAndPull
                    ..continuous = isContinuous
                   /// Add authentication.
                    ..authenticator = BasicAuthenticator(
                      _couchbaseConfig.username,
                      _couchbaseConfig.password,
                    )
                  ..channels=['listitem1'];

        log('replicate channels: ${config.channels}');

        replicator = Replicator(config);
       replicator?.addDocumentReplicationListener((replication)  {
            print('addDocumentReplicationListener');
            print(replication.documents);
          for (var document in replication.documents) {
              print('document');
              print(document);
          }
          });
            /// Listen to replicator change events.
            _listenerToken = replicator!.addChangeListener((ReplicatorChange event) async {
              if (event.status.error != null) {
                log('Error code : ${event.status.error}');
                mOnDataSyncListener?.onFailure('${event.status.error}');
              } else if (event.status.activity == ReplicatorActivityLevel.stopped) {
                log('changed listener trig: ${event.status.activity}');
                mOnDataSyncListener?.onSuccess();
                log('replicator.toJson(): ${ event.replicator.config.toJson()}');
      
              } else {
                log('changed: ${event.status.activity}');
              }
            });
            /// Start replication.
      await replicator?.start();