Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RealtimeObject.room(id, cb)并没有执行cb #37

Closed
liuyanghejerry opened this issue Mar 28, 2015 · 5 comments
Closed

RealtimeObject.room(id, cb)并没有执行cb #37

liuyanghejerry opened this issue Mar 28, 2015 · 5 comments

Comments

@liuyanghejerry
Copy link

https://github.com/leancloud/js-realtime-sdk/blob/master/src/AV.realtime.js#L966

即使id是一个已经存在的roomId,该callback并不会执行,与文档https://leancloud.cn/docs/js_realtime.html#RealtimeObject_room-1 相悖。

@liuyanghejerry
Copy link
Author

另外,RealtimeObject.room(id, cb)也没有向服务端发起sign请求,而websocket的帧当中也没有join相关的操作。

@wangxiao
Copy link
Contributor

非常感谢,对你使用产生的问题非常抱歉,已经提交代码,会尽快发布。
#38

@wangxiao
Copy link
Contributor

已经修正发布 2.0.1 版本 https://github.com/leancloud/js-realtime-sdk/releases/tag/2.0.1

@liuyanghejerry
Copy link
Author

建议realtimeObject.room()方法中的cb回调,能将room对象直接作为参数,因为这个回调执行的比room方法返回还早:

someVar.room = null;
someVar.room = realtimeObj.room(roomId, function() {console.log(someVar.room)})
// oops, console.log prints null.
// Because callback is called before the room is returned.

而如果使用room作为回调参数的话:

 realtimeObj.room(roomId, function(room) {console.log(room)})
// this seems fine.

Node.js当中,对于这样的情况使用nextTick来调用回调,但是浏览器里就只有个setTimeout,比较丑陋,如果忍受不了这样丑陋,起码应该给这个回调一个room作为参数。

@wangxiao
Copy link
Contributor

好的,这种情况我考虑一下。单独另外弄个 issue 吧,感谢反馈。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants