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 seperate functions. So, each managing independent parts of the state.

Ecolyo Store Structure

Reducer Type Description
global GlobalState store global states such as: notification, type device or fluid type

GlobalState enum
- screenType = ScreenType
- challengeExplorationNotification = boolean
- challengeActionNotification = boolean
- challengeDuelNotification = boolean
- analysisNotification = boolean
- fluidStatus = FluidStatus[]
- fluidTypes = FluidType[]
profile Profile store states about profile information such as: notification, connectionDate, profileType
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
modal ModalState store opening state of the feedback modal

ModalState enum
- isFeedbacksOpen = boolean
challenge ChallengeState store challenge state such as: list of user challenge, data load and current challenge

ChallengeState enum
- userChallengeList = UserChallenge[]
- currentChallenge = UserChallenge
- currentDataload = Dataload[]

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.