Skip to content

Commit

Permalink
fix!: more comprehensive usage of types (#65)
Browse files Browse the repository at this point in the history
Release-As: 0.4.5
  • Loading branch information
holtgrewe authored Jan 31, 2024
1 parent c1c2ff3 commit 74758a2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 deletions src/store/seqvarInfo/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const useSeqvarInfoStore = defineStore('seqvarInfo', () => {
const txCsq = ref<SeqvarResultEntry[] | undefined>(undefined)

/** Promise for initialization of the store. */
const loadDataRes = ref<Promise<any> | undefined>(undefined)
const initializeRes = ref<Promise<any> | undefined>(undefined)

/** Clear all data in the store. */
const clearData = () => {
Expand All @@ -51,16 +51,16 @@ export const useSeqvarInfoStore = defineStore('seqvarInfo', () => {
}

/**
* Load data from the server.
* Initialize and oad data from the server.
*
* @param seqvar$ The sequence variant to use for the query.
* @param forceReload Whether to force-reload in case the variant is the same.
* @returns
*/
const loadData = async (seqvar$: Seqvar, forceReload: boolean = false) => {
const initialize = async (seqvar$: Seqvar, forceReload: boolean = false) => {
// Protect against loading multiple times.
if (!forceReload && storeState.value !== StoreState.Initial && equal(seqvar$, seqvar.value)) {
return loadDataRes.value
return initializeRes.value
}

// Clear against artifact
Expand All @@ -74,7 +74,7 @@ export const useSeqvarInfoStore = defineStore('seqvarInfo', () => {
let hgncId = ''

// Retrieve variant information from annonars and mehari.
loadDataRes.value = Promise.all([
initializeRes.value = Promise.all([
annonarsClient.fetchVariantInfo(seqvar$).then((data) => {
varAnnos.value = data.result
}),
Expand Down Expand Up @@ -117,19 +117,19 @@ export const useSeqvarInfoStore = defineStore('seqvarInfo', () => {
storeState.value = StoreState.Error
})

return loadDataRes.value
return initializeRes.value
}

return {
loadDataRes,
initializeRes,
storeState,
seqvar,
varAnnos,
geneClinvar,
geneInfo,
hpoTerms,
txCsq,
loadData,
initialize,
clearData
}
})
4 changes: 2 additions & 2 deletions src/store/strucvarInfo/store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('svInfo store', () => {
const store = useStrucvarInfoStore()

// act:
await store.loadData(structuredClone(strucvarInfo))
await store.initialize(structuredClone(strucvarInfo))

// assert:
expect(store.storeState).toBe(StoreState.Active)
Expand All @@ -126,7 +126,7 @@ describe('svInfo store', () => {
const store = useStrucvarInfoStore()

// act:
await store.loadData(structuredClone(strucvarInfo))
await store.initialize(structuredClone(strucvarInfo))

// assert:
expect(store.storeState).toBe(StoreState.Error)
Expand Down
6 changes: 3 additions & 3 deletions src/store/strucvarInfo/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ export const useStrucvarInfoStore = defineStore('strucvarInfo', () => {
}

/**
* Load data from the server.
* Initialize and load data from the server.
*
* @param strucvar$ The structural variant to use for the query.
* @param forceReload Whether to force-reload in case the variant is the same.
*/
const loadData = async (strucvar$: Strucvar, forceReload: boolean = false) => {
const initialize = async (strucvar$: Strucvar, forceReload: boolean = false) => {
// Protect against loading multiple times.
if (
!forceReload &&
Expand Down Expand Up @@ -104,6 +104,6 @@ export const useStrucvarInfoStore = defineStore('strucvarInfo', () => {
genesInfos,
clinvarSvRecords,
clearData,
loadData
initialize
}
})

0 comments on commit 74758a2

Please sign in to comment.