As with the existing refine.bio, when users visit the compendia page, we want to be able to display the available downloadable compendia for the normalized and RNA-seq sample.
Problem or idea
We'll implement the hook useCompendia which includes the states and methods required to render the compendia data in UI and handle the file download.
Each exposed method of this manager should correspond to the behavior of the application and indirectly communicates with the API using the refinebio-js helper.
The implementation details and pseudocode is as follows:
❚ State Management
The hook contains the following states.
compendia: (an object) the compendia data fetched from API
setCompendia: an async method for setting compendia
loading: (boolean) the loading indicator for the compendia data
setLoading: an async method for setting loading
❚ Method
These methods are primarily used in the UI and each one corresponds to a specific application behavior.
Context
As with the existing refine.bio, when users visit the compendia page, we want to be able to display the available downloadable compendia for the normalized and RNA-seq sample.
Problem or idea
We'll implement the hook
useCompendia
which includes the states and methods required to render the compendia data in UI and handle the file download.Each exposed method of this manager should correspond to the behavior of the application and indirectly communicates with the API using the refinebio-js helper.
The implementation details and pseudocode is as follows:
❚ State Management
The hook contains the following states.
compendia
: (an object) the compendia data fetched from APIsetCompendia
: an async method for settingcompendia
loading
: (boolean) the loading indicator for the compendia datasetLoading
: an async method for settingloading
❚ Method
These methods are primarily used in the UI and each one corresponds to a specific application behavior.
(Parameters marked with * are required).
getCompendia(quantSfOnly = boolean, token = null) return void
get
methodsetCompendia
downloadCompendia(id*, token*) return object
get
methodnavigateToFileDownload(organism*, url*) return void
Example: We'll make the API request to the compendia endpoint by calling
getCompendia
from the compendia page component for the RNA-seq Sample tab:Solution or next step