redux-firestore
redux-firestore copied to clipboard
feat(query): method for clearing all listeners
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",
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?
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 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 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 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 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?