stinsen icon indicating copy to clipboard operation
stinsen copied to clipboard

Passing global stateful object around coordinators and views

Open razvanrujoiu opened this issue 2 years ago • 2 comments

I have a root coordinator and multiple child coordinators, and i am trying to pass and @EnvironmentObject around to the child coordinators to pass it further to the child views but i’m getting this warning: “Accessing StateObject’s object without being installed on a View. This will create a new instance each time”. How can i pass a global stateful object around whitout getting this?

razvanrujoiu avatar Apr 03 '22 11:04 razvanrujoiu

also

zhouxl avatar May 26 '22 14:05 zhouxl

I use the ObservableObject instead.

lonkly avatar Jul 02 '22 13:07 lonkly

This is not a proper use case of StateObject or, frankly, dependency injection and not a Stinsen issue.

https://www.avanderlee.com/swiftui/stateobject-observedobject-differences/

LePips avatar Dec 23 '22 00:12 LePips