Skip to content
Discussion options

You must be logged in to vote

Hey Dmitry :)
Part of the problem is that onReceive is inside WithViewStore. This means it will be recreated whenever state changes, which will occur when either of the timer values change. Keep in mind onReceive is going to emit the initial value as the view appears as well.

Here is an example to highlight how state changes are going to impact your view.

struct TestView: View {
  var body: some View {
    VStack {
      WithViewStore(store.scope(state: \.firstTimer)) {
        Text("firstTimer \($0.state)")
      }

      WithViewStore(store.scope(state: \.secondTimer)) {
        Text("secondTimer \($0.state)")
      }

      WithViewStore(store.stateless) { actions in
        Button("In…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@satanworker
Comment options

@iampatbrown
Comment options

Answer selected by satanworker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants