@logux/vuex
Advanced tools
Comparing version
# Change Log | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
## 0.9.9 | ||
* Fix `useSubscription` subscribing on the same channels. | ||
## 0.9.8 | ||
@@ -5,0 +8,0 @@ * Fix `useSubscription` types, `options` argument can be undefined. |
@@ -62,3 +62,3 @@ import { | ||
* @param channels Channels to subscribe. | ||
* @param opts Options. | ||
* @param options Options. | ||
* @return `true` during data loading. | ||
@@ -65,0 +65,0 @@ */ |
import { useStore } from 'vuex' | ||
import { | ||
ref, | ||
unref, | ||
isRef, | ||
watch, | ||
reactive, | ||
computed, | ||
@@ -17,13 +17,16 @@ onBeforeUnmount | ||
if (isRef(channels) || isFunction(channels)) { | ||
let channelsRef = isFunction(channels) ? computed(channels) : channels | ||
let channelsIsFunction = isFunction(channels) | ||
let subscriptions = computed(() => unifyChannelsObject(channelsRef.value)) | ||
let id = computed(() => subscriptionsId(subscriptions.value)) | ||
if (isRef(channels) || channelsIsFunction) { | ||
let state = reactive({ | ||
ref: channelsIsFunction ? computed(channels) : channels, | ||
subscriptions: computed(() => unifyChannelsObject(state.ref)), | ||
id: computed(() => subscriptionsId(state.subscriptions)) | ||
}) | ||
watch(id, (newId, oldId, onInvalidate) => { | ||
watch(() => state.id, (newId, oldId, onInvalidate) => { | ||
let ignoreResponse = false | ||
let oldSubscriptions = unref(subscriptions) | ||
let { subscriptions: oldSubscriptions } = state | ||
subscribe(store, subscriptions.value).then(() => { | ||
subscribe(store, state.subscriptions).then(() => { | ||
if (!ignoreResponse) { | ||
@@ -30,0 +33,0 @@ isSubscribing.value = false |
{ | ||
"name": "@logux/vuex", | ||
"version": "0.9.8", | ||
"version": "0.9.9", | ||
"description": "Vuex compatible API for Logux", | ||
@@ -48,2 +48,7 @@ "keywords": [ | ||
}, | ||
"./utils/package.json": "./utils/package.json", | ||
"./utils": { | ||
"require": "./utils/index.cjs", | ||
"import": "./utils/index.js" | ||
}, | ||
"./store/package.json": "./store/package.json", | ||
@@ -53,9 +58,4 @@ "./store": { | ||
"import": "./store/index.js" | ||
}, | ||
"./utils/package.json": "./utils/package.json", | ||
"./utils": { | ||
"require": "./utils/index.cjs", | ||
"import": "./utils/index.js" | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
53704
0.41%1442
0.42%