@jcbuisson/express-x-client 3.1.2 → 3.1.6
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/package.json +1 -1
- package/src/client.mts +8 -4
package/package.json
CHANGED
package/src/client.mts
CHANGED
|
@@ -71,7 +71,7 @@ export function createClient(socket, options={}) {
|
|
|
71
71
|
if (!action2service2handlers[action]) action2service2handlers[action] = {}
|
|
72
72
|
const serviceHandlers = action2service2handlers[action]
|
|
73
73
|
const handler = serviceHandlers[name]
|
|
74
|
-
if (handler) handler(result)
|
|
74
|
+
if (handler) Promise.resolve(handler(result)).catch(err => console.error('service-event handler error', name, action, err))
|
|
75
75
|
})
|
|
76
76
|
|
|
77
77
|
async function serviceMethodRequest(name, action, serviceOptions, ...args) {
|
|
@@ -415,9 +415,13 @@ export function offlinePlugin(app) {
|
|
|
415
415
|
})
|
|
416
416
|
}
|
|
417
417
|
// 2- delete elements from indexedDB cache
|
|
418
|
-
|
|
419
|
-
await idbValues.
|
|
420
|
-
|
|
418
|
+
if (deleteClient.length > 0) {
|
|
419
|
+
await idbValues.db.transaction('rw', [idbValues, idbMetadata], async () => {
|
|
420
|
+
for (const [uid] of deleteClient) {
|
|
421
|
+
await idbValues.delete(uid)
|
|
422
|
+
await idbMetadata.delete(uid)
|
|
423
|
+
}
|
|
424
|
+
})
|
|
421
425
|
}
|
|
422
426
|
// 3- update elements of cache with server's newer version
|
|
423
427
|
for (const [elt, serverMeta] of updateClient) {
|