Skip to content
Snippets Groups Projects
redux.md 4.59 KiB
Newer Older
  • Learn to ignore specific revisions
  • # Redux
    
    There are two main store created for this app:
    
    - Cozy: store information about cozy (konnectors, accounts, settings, db)
    - Ecolyo: store all states used for this app
    
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    For a better state management, combineReducers(reducers) is used to split the reducing function into separate functions. So, each managing independent parts of the state.
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    ## Ecolyo Store Structure
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    The ecolyo store [is composed](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/ecolyo/-/blob/dev/src/store/index.ts#L48-L56) with multiple stores.
    
    
    | Reducer   | Type           | Description                                                                                                                                                                                                                                                                                                                                                                    |
    | --------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    | analysis  | [AnalysisState](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/ecolyo/-/blob/dev/src/models/analysis.model.ts) | store analysis data related to user navigation                                                                                                                                      |
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    | challenge | [ChallengeState](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/ecolyo/-/blob/dev/src/models/challenge.model.ts) | store challenge state such as: list of user challenge, data load and current challenge <br><br>ChallengeState enum<br>- _userChallengeList = UserChallenge[]_<br>- _currentChallenge = UserChallenge_<br>- _currentDataload = Dataload[]_                                                                                                                                      |
    | chart     | [ChartState](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/ecolyo/-/blob/dev/src/models/chart.model.ts)     | store consumption chart states such as: timeStep, graph data<br><br>ChartState enum<br>- _selectedDate = DateTime_<br>- _currentTimeStep = TimeStep_<br>- _currentIndex = number_<br>- _currentDatachart = Datachart_<br>- _currentDatachartIndex = number_<br>- _loading = boolean_                                                                                           |
    | global    | [GlobalState](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/ecolyo/-/blob/dev/src/models/global.model.ts)    | store global states such as: notification, type device or fluid type<br><br>GlobalState enum<br>- _screenType = ScreenType_<br>- _challengeExplorationNotification = boolean_<br>- _releaseNotes = ReleaseNotes_<br>- _termsStatus = TermsStatus_<br>- _openPartnersIssueModal = boolean_<br>- _challengeActionNotification = boolean_<br>- _challengeDuelNotification = boolean_<br>- _analysisNotification = boolean_<br>- _fluidStatus = FluidStatus[]_<br>- _fluidTypes = FluidType[]_ |
    | modal     | [ModalState](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/ecolyo/-/blob/dev/src/models/modal.model.ts)     | store opening state of modals                                                                                                                                                                                                                                                                            |
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    | profile   | [Profile](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/ecolyo/-/blob/dev/src/models/profile.model.ts)        | store states about profile information such as: notification, connectionDate
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    | profileEcogesture   | [ProfileEcogestureState](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/ecolyo/-/blob/dev/src/models/profileEcogesture.model.ts)        | store states about user's profileEcogesture filled through the profile ecogesture form
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    | profileType   | [ProfileTypeState](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/ecolyo/-/blob/dev/src/models/profileType.model.ts)        | store states about user's profileType filled through the profile form
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    ## Updating state process
    
    
    Redux-thunk middleware is configured. For now, it is used only for updating the profile.
    To update a state, a webservice method is called before trigger a state change inside the store.