Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance #160

Closed
skywalkerlw opened this issue Sep 14, 2020 · 3 comments
Closed

Performance #160

skywalkerlw opened this issue Sep 14, 2020 · 3 comments

Comments

@skywalkerlw
Copy link

You refer store object even though it's used only for dispatching action. Does it bring extra performance loss since any change in store will trigger view re-rendering? If yes, what is the good way to minimize this kind of loss?

struct MyView: View {

  let store: MyStore

  var body: some View {
    UseState(store) { state in
      Text(state.name)
      Button(action: {
        self.store.myAction()
      }) {
        Text("Action")
      }
    }
  }
}
@muukii
Copy link
Collaborator

muukii commented Sep 18, 2020

@swiftyui

You can specify how you update the UI with.
From that code you pasted, I think the inside code of UseState, actually they need state.name.
So, UseState can focus on only updates name.

UseState(store, .map(\.name)) { name in
  ...
}

However, this code might affect the side of deriving the value processing.
Currently, Store updates might cause re-render every time.

@muukii
Copy link
Collaborator

muukii commented Sep 18, 2020

Ah, I could have an improvement idea that reduces updating UI.
I'll dig in later.

@skywalkerlw
Copy link
Author

i saw you have something shining merged, and we don't need to worry about performance ,right?
Is there any benchmark test for this improvement?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants