@live-change/vue3-components 0.8.107 → 0.8.108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/logic/synchronized.js +12 -3
- package/package.json +3 -3
package/logic/synchronized.js
CHANGED
|
@@ -25,7 +25,8 @@ function synchronized(options) {
|
|
|
25
25
|
recursive = false,
|
|
26
26
|
throttle = 0,
|
|
27
27
|
debounce = 300,
|
|
28
|
-
autoSave = true
|
|
28
|
+
autoSave = true,
|
|
29
|
+
updateDataProperty = undefined
|
|
29
30
|
} = options
|
|
30
31
|
if(!source) throw new Error('source must be defined')
|
|
31
32
|
if(!update) throw new Error('update function must be defined')
|
|
@@ -57,7 +58,11 @@ function synchronized(options) {
|
|
|
57
58
|
// console.log("SOURCE JSON", JSON.stringify(source.value))
|
|
58
59
|
// console.log("SYNCHRONIZED JSON", JSON.stringify(synchronizedValue.value))
|
|
59
60
|
try {
|
|
60
|
-
|
|
61
|
+
if(updateDataProperty) {
|
|
62
|
+
await update({ [updateDataProperty]: data, [timeField]: lastLocalUpdate.value, ...unref(identifiers) })
|
|
63
|
+
} else {
|
|
64
|
+
await update({ ...data, [timeField]: lastLocalUpdate.value, ...unref(identifiers) })
|
|
65
|
+
}
|
|
61
66
|
try { onSave() } catch(e) { console.error("ON SAVE HANDLER ERROR", e) }
|
|
62
67
|
} catch(e) {
|
|
63
68
|
if(resetOnError) synchronizedValue.value = copy(source.value)
|
|
@@ -103,7 +108,11 @@ function synchronized(options) {
|
|
|
103
108
|
<= ((source.value && source.value[timeField]) ?? ''))) return false // identical, no need to save
|
|
104
109
|
const data = JSON.parse(JSON.stringify(local.value))
|
|
105
110
|
try {
|
|
106
|
-
|
|
111
|
+
if(updateDataProperty) {
|
|
112
|
+
await update({ [updateDataProperty]: data, [timeField]: lastLocalUpdate.value, ...unref(identifiers) })
|
|
113
|
+
} else {
|
|
114
|
+
await update({ ...data, [timeField]: lastLocalUpdate.value, ...unref(identifiers) })
|
|
115
|
+
}
|
|
107
116
|
try { onSave() } catch(e) { console.error("ON SAVE HANDLER ERROR", e) }
|
|
108
117
|
} catch(e) {
|
|
109
118
|
if(resetOnError) synchronizedValue.value = source.value
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/vue3-components",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.108",
|
|
4
4
|
"description": "Live Change Framework - vue components",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
},
|
|
22
22
|
"homepage": "https://github.com/live-change/live-change-stack",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@live-change/vue3-ssr": "^0.8.
|
|
24
|
+
"@live-change/vue3-ssr": "^0.8.108",
|
|
25
25
|
"debug": "^4.3.4",
|
|
26
26
|
"mitt": "3.0.1",
|
|
27
27
|
"vue": "^3.4.29"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "b272a01967e326d10874fea13353ab8fa5c30fe8"
|
|
30
30
|
}
|