Sure, sorry for the explanation, now that I read through it again I'm also having a hard time understanding it 
Maybe a bit of context will help. I'm developing a Redux-like store architecture, much like The Composable Architecture. There are two ways to share the "store" between views. Either you make it an environment object, like in Recombine, or you pass it down in between each view using @ObservedObject, like in the aforementioned Composable Architecture. Each one of these methods has its own issues. Using the environment means that all the views will make a diff every single time some state changes, and passing down the store in between each view means tons of boilerplate, heavy view initialisation, and if you don't scope/lens the state yourself you'll also end up forcing a diff on all the views.
With my architecture I want the least boilerplate possible with the best performance possible. That's where the @Store property wrapper comes in – you just input the state your view wants in a keypath, and the store will be automatically scoped/lensed, so that your view only refreshes when meaningful state changes.
Here's some code of what I'd like to achieve:
@propertyWrapper struct Store<State, Action, LocalState>: DynamicProperty {
@EnvironmentObject private var store: CentralStore<State, Action>
var wrappedValue: LocalStore<LocalState, Action>
private var cancellable: AnyCancellable?
init(state: KeyPath<CentralStore.State, LocalState>) {
cancellable = store
.objectWillChange // Custom publisher which carries type metadata about which state will change
.cancel(when: { typeMetadata in !typeMetadata.isContainedIn(state) }) // cancel the publisher upstream when the type which changed isn't in the keypath, so that the view doesn't reload
.sink { _ in }
self.wrappedValue = LocalStore(lensing: store, stateKeyPath: state)
}
}
Here is my issue: DynamicProperty makes the view reload whenever the @EnvironmentObject store property receives an objectWillChange signal. Thus, a possible solution could be to stop the objectWillChange publisher from ever reaching the store property when the types don't match up.
I'm simply unsure how this could be done. I've explored making the objectWillChange a ConnectablePublisher, but that won't work since I'd still want the objectWillChange to publish to other views which might be interested in the state change, and anyways you can only connect()/cancel() once.
So I basically need a way to position myself in between the objectWillChange publisher and the @EnvironmentObject property wrapper, to block it whenever the state update doesn't line up with the given keypath.
I'd be grateful for any ideas!