Open riksnelders opened 5 years ago
Hello, thanks for your feature request! I've always been able to manually just loop over all open channels like so: eg.
function closeAndClearModules ({dispatch}) {
dispatch('user/closeDBChannel', {clearModule: true}, {root: true})
.catch(console.error)
dispatch('lists/closeDBChannel', {clearModule: true}, {root: true})
.catch(console.error)
dispatch('items/closeDBChannel', {clearModule: true}, {root: true})
.catch(console.error)
}
Does this give an error for you? If so, please tell me the error.
Thanks for the idea. I am thinking of improving the next big version by giving the ability to see which channels are open and a pre-made function that can close all of them at once.
Hey @mesqueeb
Currently in the following scenario: Using it to switch between user/companyId for the records. So whenever another entity is selected the following happens:
Clear all modules hardcoded (as u did) in a promise wich resolves when they are done
commit('locations/RESET_VUEX_EASY_FIRESTORE_STATE')
....
resolve()
Then fetchesandAdds the bigger collections and after opens the dbchannel to prevent crashes
Even know it resolves in this error being thrown
Uncaught (in promise) TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at Store.RESET_VUEX_EASY_FIRESTORE_STATE (index.esm.js?34ed:276)
at wrappedMutationHandler (vuex.esm.js?2f62:714)
at commitIterator (vuex.esm.js?2f62:382)
at Array.forEach (<anonymous>)
at eval (vuex.esm.js?2f62:381)
at Store._withCommit (vuex.esm.js?2f62:512)
at Store.commit (vuex.esm.js?2f62:380)
at boundCommit (vuex.esm.js?2f62:325)
at eval (store.js?c0d6:131)
@riksnelders Hi!
That's weird... One of these Object.keys
functions is being passed undefined
or null
:
https://github.com/mesqueeb/vuex-easy-firestore/blob/dev/src%2Fmodule%2Fmutations.ts#L42
Can you click on the
"at Store.RESET_VUEX_EASY_FIRESTORE_STATE (index.esm.js?34ed:276)"
and follow the stack trace and let me know which one?
This never happened to me.
commits are synchronous so it doesn't matter if you wrap them in a promise and "resolve" it. eg.
await resetAllModules()
// is the exact same as
resetAllModules()
if inside your "resetAllModules" function you only make commits that is.
I removed the code for now so I can't recheck.
It might be because some channel wasn't opened yet ? I don't know.
After about two years of open source, I finally got accepted for Github Sponsors!
A little about me:
BTW, donations get's paid DOUBLE by GitHub! (they're alchemists... 🦾)
Going forward 👨🏼💻
As per version 1.35.2
, you are able to close channels at any time, thanks to the stop()
function, please check the updated documentation. A closeAllChannels
method will likely be added in the future, this is issue #240.
As for a method to retrieve all open channels, would you please give us some information on why you need it? I'm not sure yet if it will be useful to many people, and it seems quite easy to accomplish by yourself. Thank you.
Currently missing feature is to completely clear all the modules at onces. When trying this in a a loop this errors out for some reason( trying to convert object to undefined or null)
Any plans for this, or an easier way so I can pass in an array of channels that I want to close ?