So, now I'm reworking a document based application using the Composable Architecture, which makes many parts of the application much easier to understand. However, I find myself thinking, "Gosh, when I mutate the app state, I really want to update the state object that the document is holding onto, so that the OS can take care of saving the changes. I thought maybe it would be good to have a top level action like StateUpdatedAction and then the top level reducer can handle that action by updating the document (which I'm storing in the environment structure). But then that makes me ask the question, "How do I make a scoped/feature level reducer handle a feature action and send out a higher level action? Or maybe do I need to handle this kind of knowledge at the top level reducer?"
But that all seems really not ergonomic, so that's probably not what I'm supposed to do.
How about, is there something that can watch the top level Store and get notified when the State changes?
We use an onChange higher-order reducer in isowords to observe state changes. It's a little messy but might help you come up with a reducer modifier you like:
Also, as an aside, our GitHub discussions page is a bit more active than this forum category if you don't get more replies here. We pushed a lot of discussion to GitHub when that feature was released in order to avoid having too many TCA-specific posts show up on the official Swift forums home page