web
web copied to clipboard
Fix subscriptions in Vuex
subscriptions are added with objects as keys which means the comparison to see if an action is already subscribed to fails and it gets readded (similarly it's impossible to unsuibscribe for)
Change:
SUBSCRIBE(state, subscription) {
state._Subscriptions.add(subscription)
},
UNSUBSCRIBE(state, subscription) {
state._Subscriptions.delete(subscription)
}
To:
SUBSCRIBE(state, subscription) {
state._Subscriptions.add(JSON.stringify(subscription))
},
UNSUBSCRIBE(state, subscription) {
state._Subscriptions.delete(JSON.stringify(subscription))
}
Both in standard Vuex modules as well as in the generated code.
https://github.com/tendermint/starport/blob/6edbc99ff58d7e8c18a2eb2671fd63feebb1d976/starport/pkg/cosmosgen/templates/vuex/store/index.ts.tpl