Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: more comprehensive usage of types #65

Merged
merged 5 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
})
Loading