@logux/vuex
Advanced tools
Comparing version 0.5.1 to 0.6.0
# Change Log | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
## 0.6.0 | ||
* Add `tag` property for component to wrap multiple children and single text | ||
* Replace shared helpers | ||
* Update dependencies | ||
## 0.5.1 | ||
@@ -5,0 +10,0 @@ * Add ES modules support |
import { | ||
subscribe, | ||
unsubscribe, | ||
unifyChannelsObject, | ||
subscriptionsId | ||
} from '../mixin/index.js' | ||
subscriptionsId, | ||
unifyChannelsObject | ||
} from '../helpers/index.js' | ||
@@ -63,3 +63,3 @@ let loguxComponent = { | ||
}, | ||
render () { | ||
render (h) { | ||
let { isSubscribing } = this | ||
@@ -72,3 +72,10 @@ let defaultSlot = this.$scopedSlots.default | ||
return defaultSlot({ isSubscribing }) | ||
let vnode = defaultSlot({ isSubscribing }) | ||
// for arrays and single text nodes | ||
if (vnode.length > 1 || !vnode[0].tag) { | ||
return h(this.tag, {}, vnode) | ||
} | ||
return vnode | ||
} | ||
@@ -75,0 +82,0 @@ } |
@@ -1,45 +0,8 @@ | ||
function unifyChannelsObject (channels) { | ||
if (!channels) { | ||
return [[{}, '']] | ||
} | ||
return channels.map(i => { | ||
let subscription = typeof i === 'string' ? { channel: i } : i | ||
return [subscription, JSON.stringify(subscription)] | ||
}) | ||
} | ||
import { | ||
subscribe, | ||
unsubscribe, | ||
subscriptionsId, | ||
unifyChannelsObject | ||
} from '../helpers/index.js' | ||
function subscriptionsId (subscriptions) { | ||
return subscriptions.map(i => i[1]).sort().join(' ') | ||
} | ||
function subscribe (store, subscriptions) { | ||
if (!store.subscriptions) store.subscriptions = { } | ||
if (!store.subscribers) store.subscribers = { } | ||
return Promise.all(subscriptions.map(i => { | ||
let subscription = i[0] | ||
let json = i[1] | ||
if (!store.subscribers[json]) store.subscribers[json] = 0 | ||
store.subscribers[json] += 1 | ||
if (store.subscribers[json] === 1) { | ||
let action = { ...subscription, type: 'logux/subscribe' } | ||
store.subscriptions[json] = store.commit.sync(action) | ||
} | ||
return store.subscriptions[json] | ||
})) | ||
} | ||
function unsubscribe (store, subscriptions) { | ||
subscriptions.forEach(i => { | ||
let subscription = i[0] | ||
let json = i[1] | ||
store.subscribers[json] -= 1 | ||
if (store.subscribers[json] === 0) { | ||
let action = { ...subscription, type: 'logux/unsubscribe' } | ||
store.log.add(action, { sync: true }) | ||
delete store.subscriptions[json] | ||
} | ||
}) | ||
} | ||
let loguxMixin = { | ||
@@ -92,8 +55,2 @@ data: () => ({ | ||
export { | ||
loguxMixin, | ||
subscribe, | ||
unsubscribe, | ||
unifyChannelsObject, | ||
subscriptionsId | ||
} | ||
export { loguxMixin } |
{ | ||
"name": "@logux/vuex", | ||
"version": "0.5.1", | ||
"version": "0.6.0", | ||
"description": "Vuex compatible API for Logux", | ||
@@ -24,3 +24,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@logux/client": "^0.8.4", | ||
"@logux/client": "^0.8.5", | ||
"@logux/core": "^0.5.3", | ||
@@ -49,2 +49,7 @@ "nanoevents": "^5.1.7" | ||
}, | ||
"./helpers/package.json": "./helpers/package.json", | ||
"./helpers": { | ||
"require": "./helpers/index.cjs", | ||
"import": "./helpers/index.js" | ||
}, | ||
"./mixin/package.json": "./mixin/package.json", | ||
@@ -51,0 +56,0 @@ "./mixin": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
50142
31
1421
Updated@logux/client@^0.8.5