WithObservationTracking with Charts #78
-
Hi, I've run into a problem recently where I am trying to access some state(marked as ObservableState) inside of a ChartContentBuilder closure. I am getting a runtime warning letting me know that I need to wrap the content with WithPerceptionTracking however I have noticed that there is no initialiser for content that conforms to ChartContent. I have naively tried to add my own extension with an init where Content: ChartContent like so: extension WithPerceptionTracking: ChartContent where Content: ChartContent { However, the content property of the WithPerceptionTracking struct is not public so that did not work. Does anyone have a workaround for this or knows why ChartContent has not been included already as part of the library? Any help would be appreciated. For reference my code looks something like this. struct MyView: View {
let store: ...
var body: some View {
Chart(store.someObservableStateProperty) {
// Some code that access another observable state property inside the store.
}
}
} I have tried wrapping the whole chart with WithObservationTracking but that did not help. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @Ilya-Floww, thanks for bringing this up! There is no real reason. We just don't use charts ourselves and so didn't even know we needed to provide support. We would happily take a PR that supports |
Beta Was this translation helpful? Give feedback.
Hi @Ilya-Floww, thanks for bringing this up! There is no real reason. We just don't use charts ourselves and so didn't even know we needed to provide support.
We would happily take a PR that supports
ChartContent
. Would you have the time to give that a shot?