[英]When Firebase query removes Observer with handle, other observers are not called
[英]Swift: Firebase auth observer not called if observers of child removed
假设ref = Firebase(url: "your firebase url")
。
ref的childRef = ref.childByAppendingPath("child")
将为childRef = ref.childByAppendingPath("child")
如果我有ref.observeAuthEventWithBlock
监听ref处的身份验证更改,然后使用childRef.removeAllObservers()
,则ref处的auth观察者不再侦听更改。
为什么是这样?
我制作了一个小应用程序来重复该问题(随后的ObjC代码)
要注意验证的代码是:
[myRootRef observeAuthEventWithBlock:^(FAuthData *authData) {
NSLog(@"got an auth event");
}];
还有子节点
child = [myRootRef childByAppendingPath:@"child_path"];
那么初始身份验证是
[myRootRef authUser:@"dude@thing.com" password:@"pw" withCompletionBlock:^(NSError *error, FAuthData *authData) {
NSLog(@"authentication 1 success");
[child removeAllObservers];
[self doAuth];
}
}];
doAuth方法仅对另一个用户进行身份验证,并输出“身份验证2成功”
got an auth event
got an auth event
authentication 1 success
authentication 2 success
因此,正如您所看到的,它可以像宣传的那样工作-我无法复制该问题。 我的猜测是错误可能在代码的其他地方。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.