When you have a reference to your store of
ReSwift.StoreType, you can use the current
state property to get to a value directly. This means you don't even need to make the object a store subscriber to grant access to some store state.
I don't recommend doing this in real code, of course. This is just like any global variable and comes with the usual problems.
But this is very nice to quickly test a new behavior in the app. Let's say you have
Presenters that are store subscribers and which configure your
View component. Adding a new configuration point is quite a bit of work since you'll have to at least modify 2 places: the presenter and its view implementation. Maybe even 3, if the view is defined as a protocol. Or even more if you add a view facade to the mix.
If you want to see how the view component will work if it had the correct values, just reach for the global state. It's there for you convenience. And when things work, you can (and should) change to a proper implementation. With unit tests and all, of course.
I bet this saved me quite some time considering how slow the Swift compiler is and how cumbersome performing all these changes for a mere smoke test would have been.
Browse the blog archive