How to observe just viewStore.send with WithViewStore? #2119
-
If we want to observe a small piece of state inside a view. We would do something like this: struct SomeView: some View {
let store: StoreOf<SomeLogic>
var body: some View {
WithViewStore(self.store, observe: \.someState) { viewStore in
Text(viewStore.someState)
}
}
} How can I achieve a similar scenario where I only need to observe sending an action? Will I just use |
Beta Was this translation helpful? Give feedback.
Answered by
Muhammed9991
May 18, 2023
Replies: 1 comment 3 replies
-
This answer by @tgrapperon answers this. For people that don't want to open the link. In instance where you are just sending an action and not displaying some information in the UI, you can create a ViewStore on the spot when you send the action: Button("Send") { ViewStore(store.stateless).send(.someAction) } |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
Muhammed9991
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This answer by @tgrapperon answers this.
#1666 (comment)
For people that don't want to open the link. In instance where you are just sending an action and not displaying some information in the UI, you can create a ViewStore on the spot when you send the action: