This app provides information about the expected rainfall in the upcoming days. It is implemented using Next.js as a React framework, MobX for state management, and Effect-Ts a zero dependency set of libraries to write purely functional TypeScript at scale.
Run yarn and then yarn startto run the app.
On this file, a sync effect is used to house the following the operations:
-
Execute the getBarChartValues method to retrieve the
amount of rainfalldata from the API. -
Execute the propagateExit method, which matches the result of the data fetching operation with the state of the HomeComponent.
-
Return the HomeComponent.
makeHome is a sync effect that contains a serie of methods that are executed based on the success of the amount of rainfall data fetch operation.
If the operation is successful the Done method will be executed, which first adds the data coming from the API to the rain data store and then renders the weather dashboard.
The rain data store houses the state that is modified and shared between all the components. It is first initialized with the data coming from the API and the minimum values for pressure and temperature.
Here the morphic package from effect-ts is used to model the data coming form the API, and make ADT manipulation easy. This package allow us to equip the types with useful operators to develop around them.