Falling for javascript..again.

I’m not going to cover all the new features, but I’d like to share one i’ve been using in my side project, Activobot.

This project is just a health & fitness app with a few simple goals:

  1. Accurately determine how many calories a person needs in a day to keep the lights on
  2. Track caloric input (from meals) & caloric output(from activities like exercises etc)

As it turns out accurately calculating the amount of calories we burn from different activities is a rather complex multi-step process!

There is an overwhelming amount of data, equations, case studies, and latin. (obligatory et all).

I started the project with swift4 in late 2017. Enums were perfect for representing different states and types for things like units of measurement. Structs I found were also perfect for representing my data structures for the user biometrics and meals.

Fast forward to NYE in 2018.
I decided to take all the old research data I’d already collected and rebuild using modern js so I could practice learning React & Redux.

For me, part of the beauty of swift is its expressivness and how it allows us to build small functional building blocks that can be composed together.

So in my path to porting code to Javascript I was first looking for a way to create something like a swift enum for some constants without a gigantic shared constants file. My original constants file was starting to get cluttered and some constant names were getting long in order to differentiate different contexts

While integrating Redux I noticed in the documentation its usage of imports to create objects representing seperate javascript constants files and decided to use the same pattern.