SaltechSystems / couchbase_lite

Flutter plugin for the Community edition of Couchbase Lite. Couchbase Lite is an embedded lightweight, document-oriented (NoSQL), syncable database engine.
MIT License
60 stars 28 forks source link

ReplicatorType.pushAndPull data push performs but pull not performing #108

Open Kazi-Wahed opened 2 years ago

Kazi-Wahed commented 2 years ago

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();