The Model layer
After I introduced this pattern in the mobile app the rest of the team and I had few brainstorming sessions to understand why this pattern was useful in the current app structure and how it could be ported and even improved in the web app codebase. Eventually this constructive sessions helped implementing an improved and novel version of this pattern that uses data marshalling to process data between the server and the client. This is an example of cross-pollination of ideas between projects, initiated by peer code review that allowed to improve a shared code pattern through team collaboration. Redux and functional concepts established a common ground for the collaboration that helped to find this new useful pattern. This wouldn’t have happened using a completely different technology for the development of the mobile app.
We did this by extracting the methods for reading and writing to the state into a lens that could be passed in as part of the configuration, as well as extracting some dependencies. This way the redux-offline library doesn’t depend on things that it only needs when an assumption is made about the type of state it’s being used with. The redux-offline-immutable-config library is then a collection of the parameters and dependencies required to use redux-offline with an immutable state specifically, while the config included within redux-offline itself is an equivalent one for a non-immutable state.