Skip to content

Commit 1928122

Browse files
committed
feat: add first-load tracking to make-get-mixin
This adds first-load tracking to the make-get-mixin, similar to what is already in the make-find-mixin.
1 parent f884531 commit 1928122

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/make-get-mixin.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,15 @@ export default function makeFindMixin(options) {
5555
const ERROR = `${prefix}Error`
5656
const GET_ACTION = `get${capitalized}`
5757
const GET_GETTER = `get${capitalized}FromStore`
58+
const HAS_ITEM_BEEN_REQUESTED_ONCE = `has${capitalized}BeenRequestedOnce`
59+
const HAS_ITEM_LOADED_ONCE = `has${capitalized}LoadedOnce`
5860
const LOCAL = `${prefix}Local`
5961
const QID = `${prefix}Qid`
6062
const ID = `${prefix}Id`
6163
const data = {
6264
[IS_GET_PENDING]: false,
65+
[HAS_ITEM_BEEN_REQUESTED_ONCE]: false,
66+
[HAS_ITEM_LOADED_ONCE]: false,
6367
[WATCH]: watch,
6468
[QID]: qid,
6569
[ERROR]: null
@@ -94,6 +98,7 @@ export default function makeFindMixin(options) {
9498
if (!this[LOCAL]) {
9599
if (this[QUERY_WHEN]) {
96100
this[IS_GET_PENDING] = true
101+
this[HAS_ITEM_BEEN_REQUESTED_ONCE] = true
97102

98103
if (idToUse != null) {
99104
return this.$store
@@ -102,6 +107,7 @@ export default function makeFindMixin(options) {
102107
// To prevent thrashing, only clear ERROR on response, not on initial request.
103108
this[ERROR] = null
104109

110+
this[HAS_ITEM_LOADED_ONCE] = true
105111
this[IS_GET_PENDING] = false
106112
return response
107113
})

0 commit comments

Comments
 (0)