Skip to content
Discussion options

You must be logged in to vote

The best solution I can think of is to have a Action.viewDidAppear action that is called so the body var can update state based on the Dependency passed down the stack

There's another option. You can use @Dependency in the initializer of your state rather than accessing it in the computed property. State is always created inside a reducer, and therefore it is covered by the cascading rules of withDependencies:

struct State {
  var showNewNav: Bool

  init() {
    @Dependency(\.flags) var featureFlags
    self.showNewNav = featureFlags.enabled && featureFlags.showNewNav
  }
}

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@patch-benjamin
Comment options

@rod-schmidt-cricut
Comment options

@patch-benjamin
Comment options

@mbrandonw
Comment options

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