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
Filter on updates not working #501
Comments
@sarensw This is actually normal behavior (because even when you change a "leaf" in the state, the root value also changes). ReSwift offers to skip identical state updates when the states conform to |
@DivineDominion , thanks a lot for the quickly reply. Interesting. I tried with I took the following selector from some of my TypeScript code. // only if the reference of .current changes, then update the component
const currentFile = useAppSelector(state => state.files.current)
// only if the length of the .files array changes, then update the component
const count = useAppSelector(state => state.files.files?.length) So I can be very specific about the updates that I want to be notified about. And I don't have to skip same values (let alone make sure that No complains here. Just something that I have to learn. One thing that I also noticed is that I can't just select any arbitrary property that I want. It feels like it has to be struct what I can filter on. But maybe I am also missing something here. |
@sarensw Swift is a bit stricter than vanilla JS when it comes to checking for value equality. It may be a good practice to slap "Equatable" onto all your subtypes just so you don't need to worry. You can select arbitrary substates, but then you need to make them a Swift tuple. These suffer from not being equatable, so you get convenient substate selection but need to (!) add the Having said that: We could copy the tuple |
Hi All, given the following class that inherits from
StoreSubscriber
, I'm trying to subscribe only to a sub-state. But even if another sub-state is updated, then this subscriber is notified about an update.My app state is:
And my reducers are:
The
SetModel
action is only called twice during startup. So I assume that "ports changed" is only printed twice (seefunc newState
in thePortWindowService
class). But even when the actionsAddVolume
orRemoveVolume
are called in a different reducer, in a different sub-state, which is not selected during subscription in theStoreSubscriber
initialization, I'll get an event andnewState
is called.What am I missing here? How can I make sure that with
store.subscribe(self) { $0.select { $0.modelState } }
newState
is only called when anything inmodelState
changes, but not involumeState
?The text was updated successfully, but these errors were encountered: