Refactor Business Logic to Composable Functions with Lodash
Imagine if looking at your business logic read as simple as a story from a children's book. That's exactly what we'll cover by learning how to compose small pieces of business logic and also set them up for further composition in the future.
We're showing a list of fictional tweets in a trivial React component created with create-react-app, however the example is not React specific and can be applied to any framework/environment.
Our example will refactor out business logic from a non-composable function to small composable pieces. To accomplish this we'll be using flow, filter and map from lodash/fp, which is included in the regular lodash npm package.
This approach works well in any environment where you're not relying on object references to your original data, as our functional approach creates new collection objects instead of mutating them.
Guide to lodash/fp: https://github.com/lodash/lodash/wiki/FP-Guide