![](/img/trans.png)
[英]Eclipse RCP: How and when to correctly unsubscribe a Composite from EventBroker?
[英]How to unSubscribe Changefeeds in RethinkDB? When changes is over
Cursor changeCursor = r.table("users").changes().run(conn);
for (Object change : changeCursor) {
System.out.println(change);
}
我只需要知道一次更改。 我知道“ changeCursor.close()”可以停止供稿。 问题是我这次如何知道更改的大小!
如果添加了三个用户,则“ System.out.println(change)”将执行紧迫时间。 如果仅添加一个用户,则“ System.out.println(change)”执行一次。 然后,我需要在RethinkDB中取消订阅Changefeed。
changeCursor.toList();
changeCursor.iterator();
什么都不做!
changeCursor.hasNext();
真的!
我不知道更改的数量。 我不知道何时执行changeCursor.close()方法。
我不太确定你在问什么。 看来您想立即获得第一个更改,然后将其关闭。
您可以使用javascrip驱动程序执行以下操作:
var r = require('rethinkdb')
r.connect({
host: 'localhost',
port: 28015,
})
.then(function(conn) {
return r.table('users').changes().run(conn)
})
.then(function(cursor) {
cursor.next()
.then(function(doc) {
console.log(doc)
//Ok, now right after we get the first doc, we will close the cursor
cursor.close()
// if we want, we can also close connection
// cursor.close().then(conn.close())
})
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.