Reputation: 91
I am using rethinkdb in my app. I can insert and retrieve data using the "rethink_db_ns" package. But I need to get data in real-time. for that, I am using This method
Future<void> getData(RethinkDb r, Connection connection) async {
var data = await r.table('users').run(connection);
List list = data.toList();
print(list);
getData(r,connection);
}
this method getting data continuously. I don't want to get the same data continuously like this. I want it only when data changes into the database. is there any better way to get changefeed.
Upvotes: 0
Views: 226
Reputation: 91
I have done this by this method :
Future<dynamic> changeFeed(RethinkDb r, Connection connection)async{
print('running async.....');
var result = await r
.table('tab_users')
.changes()
.run(connection).then((value) {
print(value);
Feed val = value;
val.forEach((element) {
print(element);
});
});
Upvotes: 0