observers

Firebase: when to call removeObserverWithHandle in swift

倾然丶 夕夏残阳落幕 提交于 2019-11-27 10:38:11
问题 Documentation says you need to call observeEventType:withBlock to remove an observer if you no longer need it. I've seen samples where it is called within ViewDidDisAppear . I also find some Obj-C code called this method within deinit , which is not ncessary in Swift. In my simple app, however, I want data to be synced as long as I am in the app. If this is the case, do I have to call observeEventType:withBlock ever? I checked the Chat-Swift sample code on Firebase website, and did not find

When should we use Observer and Observable?

若如初见. 提交于 2019-11-26 11:59:13
An interviewer asked me: What is Observer and Observable and when should we use them? I wasn't aware of these terms, so when I got back home and started Googling about Observer and Observable , I found some points from different resources: 1) Observable is a class and Observer is an interface. 2) The Observable class maintains a list of Observer s. 3) When an Observable object is updated, it invokes the update() method of each of its Observer s to notify that, it is changed. I found this example: import java.util.Observable; import java.util.Observer; class MessageBoard extends Observable {

When should we use Observer and Observable?

别等时光非礼了梦想. 提交于 2019-11-26 02:39:38
问题 An interviewer asked me: What is Observer and Observable and when should we use them? I wasn\'t aware of these terms, so when I got back home and started Googling about Observer and Observable , I found some points from different resources: 1) Observable is a class and Observer is an interface. 2) The Observable class maintains a list of Observer s. 3) When an Observable object is updated, it invokes the update() method of each of its Observer s to notify that, it is changed. I found this