Alternative option to initial onChange callback for EmptyView

I am exploring on managing state in SwiftUI app with purpose built Views due to the advantages for managing dependency with Environment.

This is the minimal example I came up with:

@MainActor
struct AsyncStateModifier<T: Equatable>: View {
    let input: T
    let action: (T) async -> Void
    @Environment var queue: AsyncActionQueue

    var body: some View {
        return EmptyView()
            .onChange(of: input, initial: true) { old, new in
                queue.process(action: action, with: input)
            }
    }
}

The drawback of this approach is initial: true allows the onChange callback to fire when view appears and since EmptyView doesn't appear the action is never executed initially.

When replacing EmptyView with Rectangle().hidden() this can be achieved, but I wanted to avoid having any impact on view hierarchy and EmptyView is suitable for that. Is there any alternative approach to make something like this possible?

I changed my approach to use ViewModifiers as which allows me to use existing view for callback:

@MainActor
struct AsyncStateModifier<T: Equatable>: ViewModifier {
    let input: T
    let action: (T) async -> Void
    let queue: AsyncActionQueue
    
    func body(content: Content) -> some View {
        return content
            .onChange(of: input, initial: true) { old, new in
                queue.process(action: action, with: new)
            }
    }
}
Alternative option to initial onChange callback for EmptyView
 
 
Q