Dimillian / SwiftUIFlux

A very naive implementation of Redux using Combine BindableObject to serve as an example
Apache License 2.0
654 stars 62 forks source link

Canvas not working on ConnectedView #9

Open joaquinperezlopez opened 4 years ago

joaquinperezlopez commented 4 years ago

Hi guys, thank you so much for this library it is very useful, I wonder whether anyone experienced the same issue that we are having right now, when we use ConnectedView class to implement map function to perform a "mapDispatchToProps", we discovered that Xcode canvas are no longer working, if we use the "brutal" option of calling directly from store.state.{myproperty} it works again.

Do you know if there is any workaround to solve this?

Thanks!

Regards

d4rkd3v1l commented 4 years ago

Same problem here... At least, per coincidence, I found a hack-around for this. 🥳🙈

I'm completely new to SwiftUI, but considering the previews are single views/view controllers. It seems legit, we have to setup the Flux stuff for each preview as well, don't we?! (Not just for the whole app, which indeed is needed for running it completely).

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        store.dispatch(action: InitFlux())
        return StoreProvider(store: store) {
            ContentView()
                .padding()
        }
    }
}

Anyway, coming from ReSwift, I was wondering why there is no "Init" Action automatically being called? So that's why I created my own one and just executed it, to ensure proper initialisation of everything.