Skip to content

Commit

Permalink
clean everything in proxy cache to ensure module and proxy is regener…
Browse files Browse the repository at this point in the history
…ated

this is especially useful for tests
  • Loading branch information
Glandos committed Mar 17, 2021
1 parent d0ab962 commit a22dd89
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@ import { extractVuexModule, getNamespacedPath } from "./module";
import { VuexModuleConstructor, Map, VuexModule, ProxyWatchers } from "./interfaces";
import { getClassPath, toCamelCase, refineNamespacedPath } from "./utils";

export function clearProxyCache<T extends typeof VuexModule>( cls :T ) {}
export function clearProxyCache<T extends typeof VuexModule>( cls :T ) {
//@ts-ignore
const VuexClass = cls as VuexModuleConstructor
delete VuexClass.prototype.__vuex_module_cache__
delete VuexClass.prototype.__vuex_proxy_cache__
delete VuexClass.prototype.__store_cache__
delete VuexClass.prototype.__vuex_local_proxy_cache__
for (const submodule of Object.values(VuexClass.prototype.__submodules_cache__)) {
clearProxyCache(submodule)
}
}

export function createProxy<T extends typeof VuexModule>( $store :any, cls :T ) :ProxyWatchers & InstanceType<T> {
//@ts-ignore
Expand Down

0 comments on commit a22dd89

Please sign in to comment.