I'm new to concepts of unidirectural architecrure and functional programming. However, I found Composable Architecture very interesting and fun to explore. I startet new project and more or less succesfully implemented everything so far, but I stumbled upon a problem which keeps me thinking for days. I hope that there is some here to push me in right direction. Problem is usage of Views in SwiftUI with Constructor Dependency Injection like SceneView.
SceneView expects to be created with Scene object and optional renderer delegate:
init(scene: SCNScene? = nil, pointOfView: SCNNode? = nil, options: SceneView.Options = , preferredFramesPerSecond: Int = 60, antialiasingMode: SCNAntialiasingMode = .multisampling4X, delegate: SCNSceneRendererDelegate? = nil, technique: SCNTechnique? = nil)
So, in order to create such view I need to put both scene and delegate in State struct because it seems that this is only way to pass some value into a view. Problem is that I think that those objects dont' belong in state, I see them as part of a environment. I can relatively easy make a warapper around them and put them in the environment, and redirect delegate calls to reducer simillary to CLMotionManager. What I don't know is how to pass that dependency to a SceneView in a View struct. What Im doing wrong?