Repository navigation
Replies: 1 comment
|
yes, save the current values when you pause and pass that array to the chart until you resume something like this, assuming your store has const [frozen, setFrozen] = useState<number[] | null>(null)
const values = useValuesStore((state) => frozen ?? state.values)
const pause = () => {
setFrozen(useValuesStore.getState().values)
}
const resume = () => {
setFrozen(null)
}use the store keeps collecting data. while paused, the selector returns the same saved array, so those updates won't rerender the chart through this subscription. resume picks up whatever's in the store now just make sure your updates create a new array and new objects for changed points. if you mutate the old ones, the paused chart's data will change too react's snapshot comparison, zustand's immutable update guide |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi.
I hope you get what i am asking.
Is it possible to bind a component to a state and "pause" it from "listening" to the state?
I want to show values on a line-chart which values update every 500ms.
So the store has a function to add the values and the values itself.
In one component I write values that come from SignalR.
My chart component renders them. But i want to "pause" the graph, while data is written in the background.
All reactions