Skip to content
Snippets Groups Projects

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

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.

Ecolyo Store Structure

The ecolyo store is composed with multiple stores.

Reducer Type Description
analysis AnalysisState store analysis data related to user navigation
challenge ChallengeState store challenge state such as: list of user challenge, data load and current challenge

ChallengeState enum
- userChallengeList = UserChallenge[]
- currentChallenge = UserChallenge
- currentDataload = Dataload[]
chart ChartState store consumption chart states such as: timeStep, graph data

ChartState enum
- selectedDate = DateTime
- currentTimeStep = TimeStep
- currentIndex = number
- currentDatachart = Datachart
- currentDatachartIndex = number
- loading = boolean
global GlobalState store global states such as: notification, type device or fluid type

GlobalState enum
- screenType = ScreenType
- challengeExplorationNotification = boolean
- releaseNotes = ReleaseNotes
- termsStatus = TermsStatus
- openPartnersIssueModal = boolean
- challengeActionNotification = boolean
- challengeDuelNotification = boolean
- analysisNotification = boolean
- fluidStatus = FluidStatus[]
- fluidTypes = FluidType[]
modal ModalState store opening state of modals
profile Profile store states about profile information such as: notification, connectionDate
profileEcogesture ProfileEcogestureState store states about user's profileEcogesture filled through the profile ecogesture form
profileType ProfileTypeState store states about user's profileType filled through the profile form

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.