@magnetarjs/plugin-vue3
Advanced tools
Comparing version 0.0.19 to 0.1.0
@@ -101,5 +101,7 @@ 'use strict'; | ||
return function ({ payload, collectionPath, docId, pluginModuleConfig, }) { | ||
if (payload && payload.ifUnfetched === true) { | ||
if (!docId) { | ||
const localDocs = [...data[collectionPath].entries()].map(([_docId, data]) => ({ | ||
const optimisticFetch = !payload || !Object.hasOwnProperty.call(payload || {}, 'force') || (payload === null || payload === void 0 ? void 0 : payload.force) === false; | ||
if (optimisticFetch) { | ||
const collectionData = data[collectionPath]; | ||
if (!docId && collectionData.size > 0) { | ||
const localDocs = [...collectionData.entries()].map(([_docId, data]) => ({ | ||
data, | ||
@@ -113,3 +115,3 @@ exists: 'unknown', | ||
if (docId) { | ||
const localDoc = data[collectionPath].get(docId); | ||
const localDoc = collectionData.get(docId); | ||
// if already fetched | ||
@@ -116,0 +118,0 @@ if (localDoc) { |
@@ -97,5 +97,7 @@ import { copy } from 'copy-anything'; | ||
return function ({ payload, collectionPath, docId, pluginModuleConfig, }) { | ||
if (payload && payload.ifUnfetched === true) { | ||
if (!docId) { | ||
const localDocs = [...data[collectionPath].entries()].map(([_docId, data]) => ({ | ||
const optimisticFetch = !payload || !Object.hasOwnProperty.call(payload || {}, 'force') || (payload === null || payload === void 0 ? void 0 : payload.force) === false; | ||
if (optimisticFetch) { | ||
const collectionData = data[collectionPath]; | ||
if (!docId && collectionData.size > 0) { | ||
const localDocs = [...collectionData.entries()].map(([_docId, data]) => ({ | ||
data, | ||
@@ -109,3 +111,3 @@ exists: 'unknown', | ||
if (docId) { | ||
const localDoc = data[collectionPath].get(docId); | ||
const localDoc = collectionData.get(docId); | ||
// if already fetched | ||
@@ -112,0 +114,0 @@ if (localDoc) { |
{ | ||
"name": "@magnetarjs/plugin-vue3", | ||
"version": "0.0.19", | ||
"version": "0.1.0", | ||
"sideEffects": false, | ||
@@ -23,3 +23,3 @@ "description": "Magnetar plugin vue3", | ||
"dependencies": { | ||
"@magnetarjs/core": "^0.0.22", | ||
"@magnetarjs/core": "^0.1.0", | ||
"copy-anything": "^2.0.3", | ||
@@ -34,3 +34,3 @@ "fast-sort": "^3.0.2", | ||
"devDependencies": { | ||
"@magnetarjs/test-utils": "^0.0.12", | ||
"@magnetarjs/test-utils": "^0.1.0", | ||
"ava": "^3.15.0", | ||
@@ -82,3 +82,3 @@ "vue": "3.0.11" | ||
}, | ||
"gitHead": "6f7e1b9b3440de3408be14439a31a9a4967377fd" | ||
"gitHead": "d5d2a2b58bdf4d7950f2532f0ad0580730fde5bd" | ||
} |
@@ -21,11 +21,12 @@ import { | ||
}: PluginFetchActionPayload<Vue3StoreModuleConfig>): FetchResponse | DoOnFetch { | ||
if (payload && payload.ifUnfetched === true) { | ||
if (!docId) { | ||
const localDocs: DocMetadata[] = [...data[collectionPath].entries()].map( | ||
([_docId, data]) => ({ | ||
data, | ||
exists: 'unknown', | ||
id: _docId, | ||
}) | ||
) | ||
const optimisticFetch = | ||
!payload || !Object.hasOwnProperty.call(payload || {}, 'force') || payload?.force === false | ||
if (optimisticFetch) { | ||
const collectionData = data[collectionPath] | ||
if (!docId && collectionData.size > 0) { | ||
const localDocs: DocMetadata[] = [...collectionData.entries()].map(([_docId, data]) => ({ | ||
data, | ||
exists: 'unknown', | ||
id: _docId, | ||
})) | ||
const fetchResponse: FetchResponse = { docs: localDocs } | ||
@@ -35,3 +36,3 @@ return fetchResponse | ||
if (docId) { | ||
const localDoc = data[collectionPath].get(docId) | ||
const localDoc = collectionData.get(docId) | ||
// if already fetched | ||
@@ -38,0 +39,0 @@ if (localDoc) { |
@@ -11,3 +11,3 @@ import test from 'ava' | ||
// try { | ||
// await trainerModule.fetch() | ||
// await trainerModule.fetch({ force: true }) | ||
// } catch (error) { | ||
@@ -26,3 +26,3 @@ // t.fail(error) | ||
// try { | ||
// await trainerModule.fetch() | ||
// await trainerModule.fetch({ force: true }) | ||
// } catch (error) { | ||
@@ -29,0 +29,0 @@ // t.fail(error) |
@@ -13,3 +13,3 @@ import test from 'ava' | ||
try { | ||
await pokedexModule.fetch() | ||
await pokedexModule.fetch({ force: true }) | ||
} catch (error) { | ||
@@ -28,3 +28,3 @@ t.fail(error) | ||
try { | ||
await trainerModule.fetch() | ||
await trainerModule.fetch({ force: true }) | ||
} catch (error) { | ||
@@ -41,3 +41,3 @@ t.fail(error) | ||
try { | ||
await trainerModule.fetch({ ifUnfetched: true }) | ||
await trainerModule.fetch() | ||
} catch (error) { | ||
@@ -53,3 +53,3 @@ t.fail(error) | ||
const queryModuleRef = pokedexModule.where('name', '==', 'Flareon') | ||
await queryModuleRef.fetch() | ||
await queryModuleRef.fetch({ force: true }) | ||
const actual = [...queryModuleRef.data.values()] | ||
@@ -67,3 +67,3 @@ const expected = [pokedex(136)] | ||
const queryModuleRef = pokedexModule.where('name', '!=', 'Bulbasaur').limit(1) | ||
await queryModuleRef.fetch() | ||
await queryModuleRef.fetch({ force: true }) | ||
const actual = [...queryModuleRef.data.values()] | ||
@@ -81,3 +81,3 @@ const expected = [pokedex(2)] | ||
const queryModuleRef = pokedexModule.where('base.HP', '==', 10) | ||
await queryModuleRef.fetch() | ||
await queryModuleRef.fetch({ force: true }) | ||
const actual = [...queryModuleRef.data.values()] | ||
@@ -95,3 +95,3 @@ const expected = [pokedex(50)] | ||
const queryModuleRef = pokedexModule.where('base.HP', '<', 11) | ||
await queryModuleRef.fetch() | ||
await queryModuleRef.fetch({ force: true }) | ||
const actual = [...queryModuleRef.data.values()] | ||
@@ -109,3 +109,3 @@ const expected = [pokedex(50)] | ||
const queryModuleRef = pokedexModule.where('base.HP', '<=', 10) | ||
await queryModuleRef.fetch() | ||
await queryModuleRef.fetch({ force: true }) | ||
const actual = [...queryModuleRef.data.values()] | ||
@@ -123,3 +123,3 @@ const expected = [pokedex(50)] | ||
const queryModuleRef = pokedexModule.where('base.HP', '>', 249) | ||
await queryModuleRef.fetch() | ||
await queryModuleRef.fetch({ force: true }) | ||
const actual = [...queryModuleRef.data.values()] | ||
@@ -137,3 +137,3 @@ const expected = [pokedex(113)] | ||
const queryModuleRef = pokedexModule.where('base.HP', '>=', 250) | ||
await queryModuleRef.fetch() | ||
await queryModuleRef.fetch({ force: true }) | ||
const actual = [...queryModuleRef.data.values()] | ||
@@ -151,3 +151,3 @@ const expected = [pokedex(113)] | ||
const queryModuleRef = pokedexModule.where('type', 'array-contains', 'Steel') | ||
await queryModuleRef.fetch() | ||
await queryModuleRef.fetch({ force: true }) | ||
const actual = [...queryModuleRef.data.values()] | ||
@@ -165,3 +165,3 @@ const expected = [pokedex(81), pokedex(82)] | ||
const queryModuleRef = pokedexModule.where('name', 'in', ['Vaporeon', 'Jolteon', 'Flareon']) | ||
await queryModuleRef.fetch() | ||
await queryModuleRef.fetch({ force: true }) | ||
const actual = [...queryModuleRef.data.values()] | ||
@@ -181,3 +181,3 @@ const expected = [pokedex(134), pokedex(135), pokedex(136)] | ||
.where('name', 'not-in', [pokedex(91).name, pokedex(131).name]) | ||
await queryModuleRef.fetch() | ||
await queryModuleRef.fetch({ force: true }) | ||
const actual = [...queryModuleRef.data.values()] | ||
@@ -195,3 +195,3 @@ const expected = [pokedex(87), pokedex(124), pokedex(144)] | ||
const queryModuleRef = pokedexModule.where('type', 'array-contains-any', ['Steel', 'Ice']) | ||
await queryModuleRef.fetch() | ||
await queryModuleRef.fetch({ force: true }) | ||
const actual = [...queryModuleRef.data.values()] | ||
@@ -219,3 +219,3 @@ const expected = [ | ||
.where('base.Speed', '>=', 100) | ||
await queryModuleRef.fetch() | ||
await queryModuleRef.fetch({ force: true }) | ||
const actual = [...queryModuleRef.data.values()] | ||
@@ -236,3 +236,3 @@ const expected = [pokedex(6), pokedex(38), pokedex(78)] | ||
.orderBy('name', 'desc') | ||
await queryModuleRef.fetch() | ||
await queryModuleRef.fetch({ force: true }) | ||
// Rapidash 78 | ||
@@ -253,3 +253,3 @@ // Ninetales 38 | ||
const queryModuleRef = pokedexModule.limit(10) | ||
await queryModuleRef.fetch() | ||
await queryModuleRef.fetch({ force: true }) | ||
const actual = [...queryModuleRef.data.values()] | ||
@@ -256,0 +256,0 @@ const expected = [ |
@@ -123,3 +123,3 @@ import test from 'ava' | ||
// // get data from server | ||
// try { await trainerModule.fetch() } catch (error) { t.fail(error) } // prettier-ignore | ||
// try { await trainerModule.fetch({ force: true }) } catch (error) { t.fail(error) } // prettier-ignore | ||
// // the server mock doesn't really update the server data | ||
@@ -169,3 +169,3 @@ // // so a fetch() call should reset the name back to 'Luca' | ||
// // // get data from server | ||
// try { await trainerModule.fetch() } catch (error) { t.fail(error) } // prettier-ignore | ||
// try { await trainerModule.fetch({ force: true }) } catch (error) { t.fail(error) } // prettier-ignore | ||
// // the server mock doesn't really update the server data | ||
@@ -172,0 +172,0 @@ // // so a fetch() call should reset the name back to 'Luca' |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
96427
2340
+ Added@magnetarjs/core@0.1.2(transitive)
- Removed@magnetarjs/core@0.0.22(transitive)
Updated@magnetarjs/core@^0.1.0