I started trying to genericize the set up of certain interconnected components this week. That has lead me to code like this:
var {
collectionStore,
itemStores,
} = assembleSubMachine({
parentStore: activeDeckIdentifier,
CollectionPersister: () => IdsPersister(deckIdsKey),
kind: 'deck',
createNewThing: createNewDeck,
RenderCollection: RenderDeckCollection,
RenderItem: RenderDeck,
ItemChangeResponder: OnDeckChange,
itemRehydrate: RehydrateDeck(thingPersister),
});
It still doesn't quite work. I have to further genericize more stuff for this to work for more than one set of components. And exactly what is that going to mean to me months later? And how applicable will my current genericization be at that point?
I started down this path because I didn't want to duplicate code between setups. It occurs to me now that it's better to either live with that or to write helper functions for parts of the setups. It will allow flexibility in setups and also be readable, or at least as readable as any of my functions are.
This is a lot easier with just one person involved. I've been in this situation before, and sometimes, the case for abandoning or redoing something has a lot more momentum to defeat when other people are invested.