redux-firestore icon indicating copy to clipboard operation
redux-firestore copied to clipboard

feat(query): method for clearing all listeners

Open Wgil opened this issue 5 years ago • 6 comments

What is the current behavior? Dispatching CLEAR_DATA action is not clearing all my listeners.

What is the expected behavior? It should clear all the listeners.

Which version of redux-firestore are you using? What about other dependencies? "redux-firestore": "^0.7.0",

Wgil avatar May 08 '19 16:05 Wgil

CLEAR_DATA is for clearing data from redux state, not actually removing listeners. A method to clear all listeners may be functionality worth adding, but it doesn't currently exist. Am I maybe misunderstanding the question?

prescottprue avatar May 31 '19 03:05 prescottprue

Hey, I thought that was the behavior of CLEAR_DATA, so I'm renaming the issue.

My current use case is that adding listeners manually and don't removing them on unmounting, when I have to logout the user, they are going to be there when it shouldn't. So probably another method to clear listeners would be useful to execute along with CLEAR_DATA.

Wgil avatar Jun 06 '19 13:06 Wgil

@Wgil I am guessing you are not using firestoreConnect for some reason? It currently handles attaching/detaching listeners on mount/unmount of react components, but you are saying that you don't want them to be removed on unmount or you do?

setListeners and unsetListeners are how that is done inside of firestoreConnect, so that is what I would suggest when doing it manually as well.

Yeah, leaving the issue for the feature of "one method to clear all listeners" makes sense. Thanks for posting.

prescottprue avatar Jun 07 '19 17:06 prescottprue

@prescottprue Hello thanks for a great library. Any update on this? This is need because I set the listeners dynamically and will not know the listeners attached when user is logging out therefore I cannot use unsetListeners since I have to know the specific query configs. A method to clear all listeners will be really helpful. Thanks

ceafive avatar Mar 11 '21 23:03 ceafive

@ceafive Thanks for outlining your use case - hopefully you should be able to loop over the listener settings which are stored on the extended Firebase instance

prescottprue avatar Apr 21 '21 13:04 prescottprue

I have the same problem. On logout I don't know which listeners to unset, since they were added dynamically.

@ceafive Thanks for outlining your use case - hopefully you should be able to loop over the listener settings which are stored on the extended Firebase instance

I couldn't find the listeners on the firebase instance. Can you explain where I can find them?

rwichmann avatar Aug 02 '21 09:08 rwichmann