我想订阅的_user表的变化,但是当我改变了出头的_user表handleEvents
不会被调用,这里就是我正在做的是:
private var parseLiveQueryClient: ParseLiveQueryClient? = ParseLiveQueryClient.Factory.getClient()
private var subscriptionHandling: SubscriptionHandling<ParseUser>? = null
private val livePointQuery = ParseUser.getQuery()
init {
subscriptionHandling = parseLiveQueryClient?.subscribe(livePointQuery)
subscriptionHandling?.handleSubscribe {
if (it != null){
Log.e("LIVE_QUERY","success") // invoked successfully
}else{
Log.e("LIVE_QUERY","null")
}
subscriptionHandling?.handleEvents { _, event, parseUser ->
Log.e("LIVE_QUERY_EVENT","${event.name}")
if(parseUser != null){
Log.e("LIVE_QUERY",parseUser.objectId)
}else{
Log.e("LIVE_QUERY","user null")
}
}
}
}
logcat的结果:
ParseLiveQueryClient: Socket onMessage {"op":"subscribed","clientId":163,"requestId":1}
P.S,我成功订阅其他表中的数据更新,例如:聊天。
解决了!这个问题是不是在客户端代码,这是在服务器端的配置,_User class
没有LiveQuery
启用,使我得到了更新后:)