Move func changing @State var in Protocol extension

I have a func, in every component, that changes @State var
I copy paste it in every in new View

I'd like to move it in Protocol(Selectable in the code example) extension
Is there any way ? I tried different cases, like mutating, so far nothing worked out.

move selection behaviour in @StateObject is undesirable

for more details check out the code example

@State var selectedItem: Item?
func select(item: Item) { selectedItem = item }
Terms of Service

Privacy Policy

Cookie Policy