,我有以下的js代码,我尝试登录该blog_root对象,然后用我的user_root听与user_root.on任何更改(“child_added”,...)火力地堡匿名用户身份验证流程
var root = new Firebase(/*my firebase url*/);
var blog_root = root.child("blog");
var user_root;
console.log("====");
blog_root.authAnonymously(function(err, authData) {
if(err){
console.log("user not authenticated?"+err);
}else{
console.log("user authenticated?"+authData.uid);
if(authData){
user_root = blog_root.child(authData.uid);
user_root.set(authData);
}
}
},{
remember: "sessionOnly"
});
user_root.on(
"child_added", //event_name
function(snapshot) {
//called for each existing element and each new element
}
使用此代码特别是我的user_root对象显示为未定义。我检查了我的数据,并且匿名用户已成功添加到blog_root,但似乎无法侦听user_root上的更改。
我收集的是在我的身份验证语句中触发了user_root.on(“child_added”)事件,但这对我来说没有意义,因为user_root是在身份验证语句中初始化的。
任何线索?
Woot!好吧,现在一切都合情合理。感谢Rob! – ebichuhamster 2014-12-10 13:44:59