[suggestion] Add scope to ViewState #85
toddwbates
started this conversation in
Ideas
Replies: 2 comments
-
I just saw episode 99 and you already have bindings. I suspect next week will cover the rest;-) |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks for starting the discussion, and sorry for not seeing till now! 😄 Going to move over to the discussions tab. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Adding the scope function allows views to deal exclusively with ViewState objects. This simplifies usage because Views are passed the object they actually use rather than having to transform the Store into a ViewStore. This also simplifies ownership.
I have also added utility methods to ViewStore for bindings that allow snapshot tests to report full coverage. For example in Counter.swift line 183
would not be reported as full coverage because of the closure while this is
The same with CounterView_macO line 57
.popover(
isPresented: Binding(
get: { self.viewStore.value.isPrimePopoverShown },
set: { _ in self.viewStore.send(.primePopoverDismissed) }
)
becomes
I have a fork with the changes here,
https://github.com/toddwbates/episode-code-samples
Beta Was this translation helpful? Give feedback.
All reactions