例如,我使用.ChildAdded事件类型调用了一次侦听器,但稍后我想再次使用.ChildRemoved侦听器调用该侦听器。
func loadMe(r: Resource<MyResourceType>, withBlock: (MyResourceType?, FIRDataEventType) -> Void) {
spinner?.startAnimating()
r.RootRef.child(r.path).observeEventType(.ChildAdded) { (snapshot: FIRDataSnapshot) in
withBlock(r.parse(snapshot.value as? FBDictionary, snapshot.key, r.path), .ChildAdded)
}
r.RootRef.child(r.path).observeEventType(.ChildRemoved) { (snapshot: FIRDataSnapshot) in
withBlock(r.parse(snapshot.value as? FBDictionary, snapshot.key, r.path), .ChildRemoved)
}
}
答案 0 :(得分:2)
创建后,Firebase事件侦听器是不可变的。因此,在注册事件类型后,您无法更改事件类型。