Skip to content

VAHub State Management and Data Retrieval

Kantemir Tvorogov edited this page Aug 9, 2023 · 1 revision

State Management

Application is using NgRx store to manage its state and data flow.
Top-level store structure is (see /src/app/common/store/reducers/index.ts):

{
    trellisingReducer: {        // used for trellising components (read "plugins") interaction
                                // see '/src/app/common/trellising/store'
        tabs: {
            [TabId]: {
                isInitialized,
                xAxis,
                yAxis,
                plots,
                legend,
                ...             // see ITab interface in '/app/common/trellising/store/ITrellising.ts'
            }
        },
        height: number
    },
    timelineReducer: {          // used for "Timeline" plugin components interaction
                                // see '/src/app/plugins/timeline/store'
        initialOpeningState,
        timelines
    },
    singleSubjectReducer: {     // used for "Single Subject" plugin components interaction
                                // see '/src/app/plugins/refactored-singlesubject/store'
        selectedSubjectId,
        subjectSearchString,
        tabs,
        isLoading
    },
    studySelection: {           // used for Study Selection page (start page) components interaction
                                // see '/src/app/studyselection/store'
        selectedDatasets,
        combinedStudyInfo,
        loading,
        searchString
    },
    detailsOnDemand: {          // used for calculating DoD columns on the "Single Subject" plugin
                                // see '/src/app/common/trellising/detailsondemand/store'
        columns
    },
    sharedStateReducer: {
        activeTabId,
        availableSubjects
    },
    availableStudies: {
        selectedDatasets,
        combinedStudyInfo,
        loading,
        searchString
    }
}

The logic for every slice of the state is placed in a separate store folder. For example for trellisingReducer there is a directory /src/app/common/trellising/store, that contains all store-related logic (actions, action creators, reducer, dispatcher).

State Persistance

For DEV environment (when VAHub is running on URL with "localhost") selected data set is stored in the localStorage.
In other cases selected dataset is not persisted.
(check classes /src/app/session/event/SessionEventService.ts and /src/app/env/EnvService.ts)

Clone this wiki locally