One Feature observing state of another (for MVVM implementation)

A trivial question perhaps, from a noob. I want to implement MVVM using TCA. actions work great - VM actions are view specific - what buttons were pressed, while M actions are state specfici - how it changes the state - and VM just translates one into sending another. It is the observing global (M) state that eludes me. I thought using @SharedReaderSharedReader in the VM to have read only access to the global (M) state. One thing I struggle with is how to get notifications in VM that the state changed. Using Actions for that feels wrong, it is just a simple observation. I am sure I miss something very obvious to the gurus here.

UPDATE: I looked at the source code for @ObservableState. There is a lot, but it all seems geared to being properly observed by a View, not by another Reducer.

UPDATE 2: I diagrammed the idea of using TCA reducers for both ViewModel and Model layers. On the diagram there is my dilemma. I have a view which needs to mix data from two Models, one of which it does not participate in editing of. So I need an observable kind of listenting from ViewModel to more than one Model, and getting an update.

Think ViewModels and Reducer+Action patterns are both used for state management and can actually substitute for one another. It’s usually better to choose one. For example, this ViewModel and Reducer are equivalent:

@MainActor
@Observable
class PlaygroundViewModel {
    var name: String = "Playground"
    
    func updateName(to newName: String) {
        self.name = newName
    }
}

@Reducer
struct PlaygroundReducer {

    struct State {
        var name: String = "Playground"
    }

    enum Action {
        case updateName(String)
    }

    var body: some Reducer<State, Action> {
        Reduce { state, action in
            switch action {
            case .updateName(let newName):
                state.name = newName
            }
        }
    }
}

And then SwiftUI/UIKit view just observers changes.

Thanks! Just to clarify, I want to use Reducers as ViewModel and Model. There is a lot that makes Reducers perfect as a ViewModel. What I struggle with, is when I make Reducer that is a ViewModel and Reducer that is a Model, I want one to observe the other and that is unclear (to me) how to do correctly

Probably this is the answer: Documentation

I am using both. MVVM is the right concept for medium to high complexity apps, I think. Redux is the right pattern for inter-module communication. TCA is the most popular Redux implmeentation for iOS, or so I am told by various AI models I cunsulted with.

So in my effort to employ TCA as an implementaiton for MVVM, I have arrived at a solution, that. I belive is cumbersome, but workable. I still think I am better off using MVVM + TCA then either of them alone.

There is a lot to like about TCA. It is great for VM. It is also great for M. It its hierarchical structure and inability to send actions directly to known features creates challenges. I can’t claim I have a well thought out alternative. I’l learn TCA more, and once I mastered it, I might want to suggest improvements.

All that said, I am a noob. So I would welcome somebody experienced present a convincing case how TCA makes MVVM unnecessary. I would love to be convinced, would make my life easier. But it would take addressing a lot of points, that post in a forum just not a good medum for. Not really expecting it be here