Unlink listener for parent does it applied to children in Firebase

后端 未结 3 1950
隐瞒了意图╮
隐瞒了意图╮ 2020-12-19 12:08

I am using firebase to synch data in a real time app. After some treatment, I want to unlink all listeners added. So I put

myRef.off();

But

3条回答
  •  旧巷少年郎
    2020-12-19 12:39

    Detach a callback previously attached with on(). Note that if on() was called multiple times with the same eventType and callback, the callback will be called multiple times for each event, and off() must be called multiple times to remove the callback.

    This comes from the firebase docs on the off() method (link).

    So if i read this correct you have to call off() for every on() you did.

提交回复
热议问题