# Non-Global View States in Swift Composable Architecture

**URL:** <https://forums.swift.org/t/non-global-view-states-in-swift-composable-architecture/42208>\
**Category:** Swift Composable Architecture\
**Tags:** swiftui\
**Created:** [November 22, 2020, 2:16am UTC](https://forums.swift.org/t/non-global-view-states-in-swift-composable-architecture/42208 "2020-11-22T02:16:45Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![nikitamounier](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/nikitamounier/32/24825_2.png) [@nikitamounier](https://forums.swift.org/u/nikitamounier)\
**Post date:** [May 31, 2021, 1:45pm UTC](https://forums.swift.org/t/non-global-view-states-in-swift-composable-architecture/42208/6 "2021-05-31T13:45:48Z")

</div>

> [@bradleygriffith](#):
>
> Im thinking of using Swift's [Environment Values](https://developer.apple.com/documentation/swiftui/environmentvalues) for this

The problem with `@Environment` and `@EnvironmentObject`, and the reason why TCA doesn't use it, is that it triggers a refresh on all the views which subscribe to it, which isn't good for performance. I [tried to solve this](https://forums.swift.org/t/block-objectwillchange-on-environmentobject/47850) by only triggering a refresh when only certain state, specified by the user, was mutated, but I wasn't able to find a solution.

I also, much like you, prefer using `@ObservedObject` over `WithViewStore`. Problem is it requires 5 lines of code compared to 2. I'm trying to solve this with a property wrapper on [another thread](https://forums.swift.org/t/wrappedstore-property-wrapper-to-get-rid-of-boilerplate/49058/4), I'd love to hear your input!

---

_[View the full topic](https://forums.swift.org/t/non-global-view-states-in-swift-composable-architecture/42208)._
