What is observe used in WithViewStore?

I keep seeing the following in the docs but not sure "whats the point" (pun intended):

WithViewStore(self.store, observe: { $0 }) { viewStore in }

I've always used it like this

WithViewStore(store) { viewStore in

Not sure why we do the observe: { $0 } and why we have to explicitly write self.store.

Hi @Muhammed9991, the documentation explains this parameter, as well as the performance article. You can also find out more info on an RFC discussion we posted a few months ago.

The explicit self. is not necessary. That is just our preferred style.


Nice one. Thanks I'll have a look.